<p>I created a deployment, a service and an Ingress to be able to access a NGINX webserver from my host, but I keep getting 404 Not Found. After a lot of hours troubleshooting, I'm getting to a point where some help would be very welcomed.</p>
<p>The steps and related yaml files are below.</p>
<p><strong>Enable Minikube NGINX Ingress controller</strong></p>
<p>minikube addons enable ingress</p>
<p><strong>Create NGINX web server deployment</strong></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: webserver-white
  labels:
    app: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx-webserver-white
  template:
    metadata:
      labels:
        app: nginx-webserver-white
    spec:
      containers:
        - name: nginx
          image: nginx:alpine
          ports:
          - containerPort: 80
</code></pre>
<p><strong>Create ClusterIP Service to manage the access to the pods</strong></p>
<pre><code>apiVersion: v1
kind: Service
metadata:
  name: webserver-white-svc
  labels:
    run: webserver-white-svc
spec:
  type: ClusterIP
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: nginx-webserver-white
</code></pre>
<p><strong>Create Ingress to access service from outside the Cluster</strong></p>
<pre><code>apiVersion: networking.k8s.io/v1 
kind: Ingress
metadata:
  name: webserver-white-ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  defaultBackend:
    service:
      name: webserver-white-svc
      port:
        number: 80
  rules:
  - host: white.example.com # This is pointing to the control plane IP
    http:
      paths:
      - backend:
          service:
            name: webserver-white-svc
            port:
              number: 80
        path: /
        pathType: ImplementationSpecific
</code></pre>
<p><strong>Tests</strong></p>
<p>When connecting to one pod and executing <code>curl http://localhost</code>, it return the NGINX homepage html, so the pod looks good.</p>
<p>When creating a testing pod and executing <code>curl http://&lt;service-cluster-ip&gt;</code>, it return the NGINX homepage html, so the service looks good.</p>
<p>When connecting to the ingress nginx controller pod and executing <code>curl http://&lt;service-cluster-ip&gt;</code>, it also return the NGINX homepage html, so the connection between the ingress controller and the service looks good.</p>
<p>When connecting to the control plane with <code>minikube ssh</code> and executing <code>ping &lt;nginx-controller-ip&gt;</code> I see that it reaches the nginx controller.</p>
<p>I tested the same, but with a NodePort Service instead of ClusterIP and noticed that I could access the NGINX homepage using the node port, but not the Ingress port.</p>
<p>Any idea what I could be doing wrong and/or what else I could do to better troubleshoot this issue?</p>
<p><strong>Other notes</strong></p>
<ul>
<li>minikube version: v1.23.0</li>
<li>kubectl version on the client and server: v1.22.1</li>
<li>OS: Ubuntu 18.04.5 LTS (Bionic Beaver)</li>
</ul>
<p><strong>UPDATE/SOLUTION:</strong></p>
<p>The solution was to add the missing annotation <code>kubernetes.io/ingress.class: &quot;nginx&quot;</code> on the Ingress.</p>

Daniel Serrão
<p>The solution was to add the missing annotation kubernetes.io/ingress.class: &quot;nginx&quot; on the Ingress.</p>
