Hi , I was attempting the INgress Networking lab, last question where it asked t . . .

Mayur Sharma:
Hi , I was attempting the INgress Networking lab, last question where it asked to write an ingress and use following annotation,
annotations:
http://nginx.ingress.kubernetes.io/rewrite-target|nginx.ingress.kubernetes.io/rewrite-target: /

It worked with this annotation and when I removed this annotation and apply the ingress, URL did not work.

Working Ingress Resource
apiVersion: http://networking.k8s.io/v1|networking.k8s.io/v1
kind: Ingress
metadata:
name: simple-fanout-example
namespace: critical-space
annotations:
http://nginx.ingress.kubernetes.io/rewrite-target|nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:

  • http:
    paths:
    • path: /pay
      pathType: Prefix
      backend:
      service:
      name: pay-service
      port:
      number: 8282

Can someone please help me to understand why it is working with annotation and failed when we remove the annotation

Ankush Chouhan:
What is the error message you getting

Mayur Sharma:
No error message in applying the Ingress, but when I hit the URL /pay it goes to 404 page

Shwetha Shenoy V:
The rewrite target annotation specifies the target path for redirection.
So, from your ingress example, any requests to http://host:port/pay is redirected to pay-service at port 8282.
Without the annotation, the request will be redirected to pay-service:8282/pay which doesn’t exist in your case. Hence, the 404.