<p>Running microk8s v1.23.3 on Ubuntu 20.04.4 LTS. I have set up a minimal pod+service:</p>
<pre><code>kubectl create deployment whoami --image=containous/whoami --namespace=default
</code></pre>
<p>This works as expected, curl <code>10.1.76.4:80</code> gives the proper reply from <code>whoami</code>.
I have a service configured, see content of <code>service-whoami.yaml</code>:</p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: whoami
  namespace: default
spec:
  selector:
    app: whoami
  ports:
    - protocol: TCP
      port: 80
      targetPort: 80
</code></pre>
<p>This also works as expected, the pod can be reached through the clusterIP on <code>curl 10.152.183.220:80</code>.
Now I want to expose the service using the <code>ingress-whoami.yaml</code>:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: whoami-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  defaultBackend:
    service:
      name: whoami
      port:
        number: 80
  rules:
  - http:
      paths:
      - path: /whoami
        pathType: Prefix
        backend:
          service:
            name: whoami
            port:
              number: 80
</code></pre>
<p>ingress addon is enabled.</p>
<pre><code>microk8s is running
high-availability: no
  datastore master nodes: 127.0.0.1:19001
  datastore standby nodes: none
addons:
  enabled:
    ha-cluster           # Configure high availability on the current node
    ingress              # Ingress controller for external access
</code></pre>
<p>ingress seems to point to the correct pod and port. <code>kubectl describe ingress</code> gives</p>
<pre><code>Name:             whoami-ingress
Labels:           &lt;none&gt;
Namespace:        default
Address:
Default backend:  whoami:80 (10.1.76.12:80)
Rules:
  Host        Path  Backends
  ----        ----  --------
  *
              /whoami   whoami:80 (10.1.76.12:80)
Annotations:  &lt;none&gt;
Events:       &lt;none&gt;
</code></pre>
<p>Trying to reach the pod from outside with <code>curl 127.0.0.1/whoami</code> gives a <code>404</code>:</p>
<pre><code>&lt;html&gt;
&lt;head&gt;&lt;title&gt;404 Not Found&lt;/title&gt;&lt;/head&gt;
&lt;body&gt;
&lt;center&gt;&lt;h1&gt;404 Not Found&lt;/h1&gt;&lt;/center&gt;
&lt;hr&gt;&lt;center&gt;nginx&lt;/center&gt;
&lt;/body&gt;
&lt;/html&gt;
</code></pre>
<p>Where did I go wrong? This setup worked a few weeks ago.</p>

<p>Ok, figured it out.
I had forgotten to specify the <code>ingress.class</code> in the annotations-block.
I updated <code>ingress-whoami.yaml</code>:</p>
<pre><code>apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  name: whoami-ingress
  namespace: default
  annotations:
    kubernetes.io/ingress.class: public
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
  - http:
      paths:
      - path: /whoami
        pathType: Prefix
        backend:
          service:
            name: whoami
            port:
              number: 80
</code></pre>
<p>Now everything is working.</p>
