首页 > 解决方案 > Google Kubernetes engine inter-cluster session affinity(Sticky Session)

问题描述

The situation is that I have 2 applications: A and B that are in the same namespace of a cluster on gke. A is on 1 pod and B is on 2 pods.

Everytime a client communicates with our service. It connects first on A with websockets. A then sends http request to B. Since there is 2 pods of B, I would like to have session affinity between the Client from outside and with my application B so that everytime a client connects to A, it will always process his requests through the same pod of B.

Every session affinity option I saw are based on Ingress gateway or services, but since I'm already in the cluster, I don't need an Ingress.

I also saw that there is some services that provides support for http cookies. That would be good but it is always an external service like Nginx or Istio and since I'm working in a highly restricted development environment it is kind of a pain to add those service in the cluster.

Is there anything native to the gke that can provide me with http cookie session affinity or something similar?

标签: kubernetesgoogle-cloud-platformgoogle-kubernetes-engine

解决方案


在 GKE 集群中,当您创建 Kubernetes Ingress 对象时,GKE Ingress 控制器会唤醒并创建 Google Cloud Platform HTTP(S) 负载平衡器。入口控制器配置负载均衡器,还配置一个或多个与负载均衡器关联的后端服务。

从 GKE 版本 1.11.3-gke.18 开始,您可以使用 Ingress 配置后端服务的这些属性:

  • 暂停
  • 连接耗尽超时
  • 会话亲和性

对你很有用,它是 GKE Ingress 的原生。


推荐阅读