sticky session - Almax84/consulting-wiki Wiki

Internal services can have sticky sessions by providing just one parameter in their manifest spec.sessionAffinity: ClientIP

kind: Service
apiVersion: v1
  name: my-service
    app: my-app
  - name: http
    protocol: TCP
    port: 80
    targetPort: 80
  sessionAffinity: ClientIP

If you also want a route with session affinity:

  1. expose the route
  2. annotate the route with sticky #or any other cookie name
  3. the client must call the route and save the cookie ex. curl -s -o /dev/null --cookie-jar cookies.txt
  4. call the route with a simple curl curl --cookie cookies.txt

OpenShift Container Platform provides sticky sessions, which enables stateful application traffic by ensuring all traffic hits the same endpoint. However, if the endpoint Pod terminates, whether through restart, scaling, or a change in configuration, this statefulness can disappear.

OpenShift Container Platform can use cookies to configure session persistence. The Ingress controller selects an endpoint to handle any user requests, and creates a cookie for the session. The cookie is passed back in the response to the request and the user sends the cookie back with the next request in the session. The cookie tells the Ingress Controller which endpoint is handling the session, ensuring that client requests use the cookie so that they are routed to the same Pod. paragrafo 9.14