Reputation: 31
404 Error with GKE ingress. I am on a Google Kubernetes cluster.
kubectl create deployment my-deploy --image=nginx
kubectl expose deployment my-deploy --name=my-svc --type=NodePort --port=80
kind: Ingress
metadata:
name: my-ingress
spec:
rules:
- host: foo.bar.com
http:
paths:
- path: /bar
backend:
serviceName: my-svc
servicePort: 80
This automatically created a LoadBalancer as expected with IP 34.95.98.151
Added an entry to my windows hosts file located under “C:\Windows\System32\drivers\etc”
On accessing http://foo.bar.com/bar from my local machine, I get the following 404 error
I was hoping for NGINX main page to show up. I would very much appreciate it if someone can help me with this.
Upvotes: 0
Views: 1125
Reputation: 1058
If NGINX itself is not serving the /bar path it would be expected to return a 404, beacuse your ingress is just passing that path along. You would get the same 404 running nginx on your computer (no k8s involved) if it wasn't serving anything on /bar.
Here I have an ingress with the /bar set in path
Change path in your yaml from: /bar
to just /
Here I have an ingress with path set to /
Or, you can create a rewrite, but I think that's more complex than you need.
https://kubernetes.github.io/ingress-nginx/examples/rewrite/#rewrite-target
Upvotes: 1