Interview Prep/Kubernetes/Services, DNS, Ingress and NetworkPolicy

ingress-nginx returns `404 Not Found` (nginx default backend) for `https://shop.example.com`, but the Ingress object exists.

BeginnerTroubleshootingServices, DNS, Ingress and NetworkPolicy
Answer

Likely causes → The controller did not pick up the Ingress or no rule matches: missing or wrong ingressClassName, host differs from the requested host (www. vs apex), path or pathType does not match, or the request reaches a different controller.

Diagnose →

kubectl get ingress shop -n shop -o yaml | yq '.spec'
kubectl get ingressclass
kubectl logs -n ingress-nginx deploy/ingress-nginx-controller | grep shop
curl -sv -H 'Host: shop.example.com' http://<lb-address>/

Fix → Set spec.ingressClassName: nginx, fix host and path (pathType: Prefix with /). Check the controller log for Ignoring ingress because of error.

Prevent → Mark one IngressClass as default (ingressclass.kubernetes.io/is-default-class: "true") and lint Ingresses in CI.

All Kubernetes questions Roadmap: Kubernetes networking, storage & scaling

More on Services, DNS, Ingress and NetworkPolicy