Jake Conkerton-Darby
Jake Conkerton-Darby

Reputation: 1101

Route traffic in kubernetes based on IP address

We have need to test a pod on our production kubernetes cluster after a data migration before we expose it to our users. What we'd like to do is route traffic from our internal ip addresses to the correct pods, and all other traffic to a maintenance pod. Is there a way we can achieve this, or do we need to briefly expose an ip address on the cluster so we can access the pods directly?

Upvotes: 0

Views: 959

Answers (1)

Olesya Bolobova
Olesya Bolobova

Reputation: 1643

What ingress controller are you using?
Generally ingress-controllers tend to support header-based routing, rather that source ip based one.

Say, ingress-nginx supports header-based canary deployments out of box. https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/annotations/#canary.

Good example here.
https://medium.com/@domi.stoehr/canary-deployments-on-kubernetes-without-service-mesh-425b7e4cc862
Note, that ingress-nginx canary implementation actually requires your services to be in different namespaces.

You could try to configure your ingress-nginx with use-forwarded-headers and try to employ X-Forwarded-For header for routing.
https://kubernetes.github.io/ingress-nginx/user-guide/nginx-configuration/configmap/#use-forwarded-headers

Upvotes: 1

Related Questions