ingress sticky session

Deployment for testing

Ingress for testing

The image used is contained / whoamI, and the effect is as follows

After changing the number of pods to 3, you can easily get the following information. The request will rotate between the three pods

Just add annotation

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  annotations:
    nginx.ingress.kubernetes.io/affinity: "cookie"
    nginx.ingress.kubernetes.io/session-cookie-name: "ingresscoookie"
    nginx.ingress.kubernetes.io/session-cookie-hash: "sha1"
    nginx.ingress.kubernetes.io/session-cookie-expires: "172800"
    nginx.ingress.kubernetes.io/session-cookie-max-age: "172800"
Send a Message