本文介绍了Google Kubernetes引擎集群间会话亲和力(Sticky Session)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这种情况是,我有2个应用程序:A和B在gke上的群集的同一命名空间中. A在1个吊舱上,B在2个吊舱上.

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.

每次客户与我们的服务进行通信时.它首先在A上通过websockets连接.然后A向B发送http请求.由于B有2个Pod,我希望外部的客户端与我的应用程序B之间具有会话亲缘关系,以便每次客户端连接到A时,它将始终通过A处理请求. B的同一个豆荚.

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.

我看到的每个会话亲缘关系选项都基于Ingress网关或服务,但是由于我已经在集群中,因此不需要Ingress.

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.

我还看到有些服务提供对HTTP cookie的支持.那样很好,但是它总是像Nginx或Istio这样的外部服务,并且由于我在高度受限的开发环境中工作,因此很难在集群中添加这些服务.

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.

gke是否有任何可以为我提供http cookie会话亲和力或类似功能的东西?

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

推荐答案

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

In a GKE cluster, when you create a Kubernetes Ingress object, the GKE ingress controller wakes up and creates a Google Cloud Platform HTTP(S) load balancer. The ingress controller configures the load balancer and also configures one or more backend services that are associated with the load balancer.

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

Beginning with GKE version 1.11.3-gke.18, you can use an Ingress to configure these properties of a backend service:

  • 超时
  • 连接耗尽超时
  • 会话亲和力

将是对您有用,它是GKE Ingress的原生工具.

This will be useful for you and it's native of GKE Ingress.

这篇关于Google Kubernetes引擎集群间会话亲和力(Sticky Session)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-14 19:38