The question asks to create ingress resource with nginx.ingress.kubernetes.io/rewrite-target, and asks to validate the result with actual test.
The cluster has ingress class named traefik and is set as default, means that any ingress resource with no explicit ingressClassName will get linked to traefik class, which leads to traefik controller being used instead of nginx ingress controller.
The problem is that nginx.ingress.kubernetes.io/rewrite-target only works on nginx controllers (as per my understanding), while traefik controller have their own different way to rewrite urls.
The provided solution on the lab uses the default ingress class, leading to traefik controller, which I think is incorrect solution
I validated the results using curl through the ingress services. Wrong setting to rewrite url will generate 404 page on payment-pod, while a proper setting will generate html with below content
<img src="https://res.cloudinary.com/cloudusthad/image/upload/v1547306802/a-customer-making-wireless-or-contactless-payment-PSWG6FE-low.jpg">
Hi @nader939
Have you done the following?
- Check what other ingress classes are available in the cluster.
- Check what ingress controller is actually deployed in the cluster by looking at the namespaces and what’s running in them?
- Set
ingressClassName
on your Ingress
resource appropriately.
Hi @Alistair_KodeKloud ,
Have you done the following?
Check what other ingress classes are available in the cluster.
Check what ingress controller is actually deployed in the cluster by looking at the namespaces and what’s running in them?
I already answered these on my question body, but let me rephrase:
- there are two ingress classes in lab environment: nginx and traefik
- traefik is made the default one, so without explicitly setting ingressClassName to nginx, then traefik will take effect
- if traefik takes effect then the question requirement of using nginx.ingress.kubernetes.io/rewrite-target will not work, since that annotation is nginx-only thing
- Here I am reporting a bug in the given lab answer, because the given answer doesn’t set ingressClassName to nginx, and just leaves it to the default traefik class
Agreed. I have reported the bug.
The solution has now been updated to include the required ingressClassName
1 Like