I have created a kubernetes cluster using Vagrant. I created a Nginx pod and a Cluster IP service for it. I can curl both the pod and the service getting a successful result. I have now installed an Nginx Ingress Controller from: https://kubernetes.github.io/ingress-nginx/deploy/#bare-metal-clusters and ran the following command:
kubectl create ingress nginxingress --rule="/nginx=nginx-service:80" --annotation nginx.ingress.kubernetes.io/rewrite-target=/ --default-backend=nginx-service:80
and they both have been setup correctly as far as I see as there are no errors. But whenever I try to curl the path then it fails, the controller keeps throwing a 404 Not found.
Some more information that might help:
services:
ingresses:
any help will be greatly appreciated
2
Answers
Try adding the ingress class annotation to the ingress configuration.
kubernetes.io/ingress.class: "nginx"
use below YAML as reference and try to update the configuration.
Had the same problem but was already using
kubernetes.io/ingress.class: "nginx"
as in Harsh Manvar answer.If you need to match multiple URLs and not only the basic host URL like me, on your ingress use:
spec.rules.[your-host].path: "/(.*)"
spec.rules.[your-host].path: Prefix
nginx.ingress.kubernetes.io/use-regex: "true"
More detail about this config here
OBS: some times update a ingress dosent work, you may need to delete and recreate the ingress.