简体   繁体   English

Kubernetes 管理一个集群中不同应用的pod副本之间的流量

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

I have a keycloak and client application on one Kubernetes node.我在一个 Kubernetes 节点上有一个密钥斗篷和客户端应用程序。 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?我有 3 个用于 keycloak 和客户端的 pod 我可以管理 kubernetes 中的流量,以便从客户端副本到 keycloak 的查询始终返回到它来自的同一个副本吗? 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:此功能称为粘性会话,可以在 Nginx 入口 controller 中配置,遵循以下注释:

https://kubernetes.github.io/ingress-nginx/examples/affinity/cookie/ 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.如果您在 AWS 中部署了所有内容,并且您使用的是 ALB 入口 controller,则可以使用粘性注释来实现此目的。

My working in production example:我在生产中的工作示例:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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