Sticky sessions
Sticky sessions, or session persistence, is when you instruct the load balancer to remain linked to a specific node (server) to avoid losing the session data if the request goes to the other server. Essentially, you send the request from a given IP to the delivery server, but continue to send follow-up requests to the same server until the session expires. Session persistence is needed when the project has transactions or required data in the session.
Sticky sessions are typically used in situations where you have some data in the session and the sessions are not replicated between servers, but you also need to ensure that the data doesn’t get lost.
Session cookie affinity
Only paths on the Ingress using
nginx.ingress.kubernetes.io/affinityuse session cookie affinity. All paths defined on other Ingresses for the host are load balanced through the random selection of a backend server.

Enable sticky sessions
To enable sticky sessions:
- Go to your
values.ymlfile in your DX Cloud project. - Set the following ingress annotations:
ingress:
enabled: true
annotations:
kubernetes.io/ingress.class: "nginx"
nginx.ingress.kubernetes.io/proxy-body-size: 512m
cert-manager.io/cluster-issuer: "letsencrypt-prod-dns"
nginx.ingress.kubernetes.io/affinity: "cookie" <1>
nginx.ingress.kubernetes.io/affinity-mode: "persistent" <2>
nginx.ingress.kubernetes.io/session-cookie-name: "INGRESSCOOKIE" <3>
nginx.ingress.kubernetes.io/session-cookie-max-age: "3600" <4>
nginx.ingress.kubernetes.io/default-backend: {{ .Env.DEPLOYMENT }}-magnolia-error-page-svc
nginx.ingress.kubernetes.io/custom-http-errors: "503"
hosts:
- host: {{ .Env.DEPLOYMENT }}.eu-playground.magnolia-platform.com
paths:
- path: /
instance: public
- path: /author
instance: author
...
Set nginx.ingress.kubernetes.io/affinity to cookie.
Set nginx.ingress.kubernetes.io/affinity-mode to persistent.
Put the INGRESSCOOKIE at nginx.ingress.kubernetes.io/session-cookie-name.
If you use a Cookie based redirect server, the name must not be the same as the value in the nginx.ingress.kubernetes.io/session-cookie-name ingress annotation in your values.yml file.
Set nginx.ingress.kubernetes.io/session-cookie-max-age to the time (in seconds) you want the cookie to persist.
After this configured time, the cookie is deleted.