GKE负载平衡器-入口-服务-会话相似性(Sticky会话) [英] GKE Load Balancer - Ingress - Service - Session Affinity (Sticky Session)

查看:110
本文介绍了GKE负载平衡器-入口-服务-会话相似性(Sticky会话)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在具有以下配置的minibike的开发环境中,我遇到了棘手的问题:

I had sticky session working in my dev environment with minibike with following configurations:

入口:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: gl-ingress
  annotations:
    nginx.ingress.kubernetes.io/affinity: cookie
    kubernetes.io/ingress.class: "gce"
    kubernetes.io/ingress.global-static-ip-name: "projects/oceanic-isotope-199421/global/addresses/web-static-ip"
spec:
  backend:
    serviceName: gl-ui-service
    servicePort: 80
  rules:
  - http:
      paths:
      - path: /api/*
        backend:
          serviceName: gl-api-service
          servicePort: 8080

服务:

apiVersion: v1
kind: Service
metadata:
  name: gl-api-service
  labels:
    app: gl-api
  annotations:
    ingress.kubernetes.io/affinity: 'cookie'
spec:
  type: NodePort
  ports:
  - port: 8080
    protocol: TCP
  selector:
    app: gl-api

现在我已经将项目部署到GKE粘性会话中,不再起作用.我相信原因是GKE中配置的Global Load Balancer与NGINX Ingress控制器没有会话亲缘关系.任何人都运气好吗?任何帮助,将不胜感激.我想建立会话关联:客户端浏览器>负载均衡器>入口>服务.实际会话位于服务后面的窗格中.它是一个API网关(由Zuul构建).

Now that I have deployed my project to GKE sticky session no longer function. I believe the reason is that the Global Load Balancer configured in GKE does not have session affinity with the NGINX Ingress controller. Anyone have any luck wiring this up? Any help would be appreciated. I wanting to establish session affinity: Client Browser > Load Balancer > Ingress > Service. The actual session lives in the pods behind the service. Its an API Gateway (built with Zuul).

推荐答案

GCE/GKE入口控制器中尚无会话亲和力.

Session affinity is not available yet in the GCE/GKE Ingress controller.

同时,作为解决方法,您可以直接使用GCE API创建HTTP负载平衡器.请注意,您不能在同一群集中同时使用Ingress.

In the meantime and as workaround, you can use the GCE API directly to create the HTTP load balancer. Note that you can't use Ingress at the same time in the same cluster.

  1. 为Kubernetes服务使用 NodePort .在spec.ports[*].nodePort中设置端口的值,否则将分配一个随机的端口
  2. 停用kube-proxy SNAT负载平衡
  3. 使用启用Cookie会话亲和力.作为后端,使用1.的端口.
  1. Use NodePort for the Kubernetes Service. Set the value of the port in spec.ports[*].nodePort, otherwise a random one will be assigned
  2. Disable kube-proxy SNAT load balancing
  3. Create a Load Balancer from the GCE API, with cookie session affinity enabled. As backend use the port from 1.

这篇关于GKE负载平衡器-入口-服务-会话相似性(Sticky会话)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆