ph_anvin
ph_anvin

Reputation: 87

Kubernetes management of traffic between pod replicas of different applications in one cluster

I have a keycloak and client application on one Kubernetes node. I have 3 pods for keycloak and client Can I manage traffic in kubernetes so that the query from the client replica to the keycloak always returns to the same replica from which it comes? For now, traffic is being redirected

client replica -> keyclok -> random client replica.

I want to get effect:

client replica x -> keycloak -> client replica x.

Thank you in advance for all the answers

Upvotes: 0

Views: 374

Answers (1)

paltaa
paltaa

Reputation: 3254

This feature is called sticky sessions, can be configured in Nginx ingress controller following these annotations:

https://kubernetes.github.io/ingress-nginx/examples/affinity/cookie/

If you have everything deployed in AWS and you are using an ALB ingress controller, you can achieve this with stickiness annotation.

My working in production example:

alb.ingress.kubernetes.io/target-group-attributes: stickiness.enabled=true,stickiness.lb_cookie.duration_seconds=6000

Upvotes: 2

Related Questions