简体   繁体   中英

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM