我正在尝试在 kubernetes 集群上实现粘性,但每次访问负载均衡器时,我都会被重定向到不同的 pod。我将会话亲和性设置为“ClientIP”,并尝试使用“生成的 Cookie”。
我已设置以下后端服务:
apiVersion: v1
kind: Service
metadata:
annotations:
beta.cloud.google.com/backend-config: '{"ports": {"80":"test-backendconfig"}}'
kubectl.kubernetes.io/last-applied-configuration: |
{"apiVersion":"v1","kind":"Service","metadata":{"annotations":{"beta.cloud.google.com/backend-config":"{\"ports\": {\"80\":\"test-backendconfig\"}}"},"labels":{"app":"test","tier":"frontend"},"name":"test","namespace":"default"},"spec":{"ports":[{"name":"backend-port","port":80,"targetPort":5000}],"selector":{"app":"test","tier":"frontend"},"sessionAffinity":"ClientIP","type":"NodePort"}}
creationTimestamp: 2018-12-31T18:01:26Z
labels:
app: test
tier: frontend
name: test
namespace: default
resourceVersion: "..."
selfLink: /api/v1/namespaces/default/services/test
uid: ...
spec:
clusterIP: 10.**.***.***
externalTrafficPolicy: Cluster
ports:
- name: backend-port
nodePort: 32385
port: 80
protocol: TCP
targetPort: 5000
selector:
app: test
tier: frontend
sessionAffinity: ClientIP
sessionAffinityConfig:
clientIP:
timeoutSeconds: 10800
type: NodePort
status:
loadBalancer: {}