Working with nginx ingress controller annotations in Kubernetes

Victor Muchiaroni
sysadmuchi
Published in
2 min readSep 23, 2020

I have spent some hours studying kubernetes and its components in the last few weeks and one of the points that took most of my time was the ingress controllers, more specifically, their annotations. Because of that, I have decided this to be the first story under this publication.

The main reason for this topic is that, during my study time, I was using nginx as ingress controller and, for some reason, I was unable to make the annotations(url rewrites, redirects etc.) to take effect during a request.

Ingress controller setup

After some troubleshooting and researches I found out that there are two types of nginx ingress controllers: one maintained by the kubernetes project and other one that is maintained by the nginx project. That was the reason the annotations were not working as they supposed to, I was mixing it up the projects and their annotations configuration.

If you are facing a similar behavior, make sure that the correct controller and annotations are in place as shown below:

If you are using the kubernetes project nginx controller check this link for the correct annotations: https://kubernetes.github.io/ingress-nginx/examples/rewrite/

If you are using the nginx project ingress controller check this link for the correct annotations: https://docs.nginx.com/nginx-ingress-controller/configuration/ingress-resources/advanced-configuration-with-annotations/

--

--