Hey so I have a load balancer setup with sticky cookies:
service.beta.kubernetes.io/do-loadbalancer-sticky-sessions-type: "cookies"
service.beta.kubernetes.io/do-loadbalancer-sticky-sessions-cookie-name: "storythreads-sticky-session"
service.beta.kubernetes.io/do-loadbalancer-sticky-sessions-cookie-ttl: "3600" # 1 hr cookie duration; I assume its refreshed each time
A big problem I have though, is those cookies are set with SameSite=Lax - which means they cant be used in fetch requests cross origin.
I really need some way of changing that to None so that I can use fetches that have stickyness.
Any advice please?
This textbox defaults to using Markdown to format your answer.
You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!
These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.
Hi Ben,
As far as I can see from the DigitalOcean Managed Load Balancer documentation, sticky sessions are implemented at the load balancer layer. The cookies used for sticky sessions are set and stripped by the load balancer before the request reaches your backend application. This means that these cookies are not available to your backend applications, making them unsuitable for backend logic or cross-origin use cases.
As per the documentation:
Also on another note, Load Balancer sticky sessions only work with:
They do not work with SSL passthrough (port 443 to 443). Make sure your load balancer is terminating SSL and forwarding the request to your backend over HTTP or HTTPS for sticky sessions to function.
As you’re deploying on Kubernetes, using an ingress controller like NGINX Ingress gives you more control over cookies. For example, you can set cookie attributes directly in the ingress annotations:
Let me know how it works for you!
- Bobby