Session stickiness is required for a legacy app. What are the options?
IntermediateScenarioServices, Ingress and DNS
Answer
Situation read → A stateful web app breaks when requests bounce between pods.
What I'd do →
- Use
sessionAffinity: ClientIPon the Service withsessionAffinityConfig.clientIP.timeoutSeconds - Prefer ingress cookie affinity such as
nginx.ingress.kubernetes.io/affinity: cookie - With ALB use target group stickiness annotations
- Plan to externalise the session to Redis, which is the real fix
- Test with several clients behind NAT
Why → ClientIP affinity is weak behind NAT or proxies, because many users share one source IP.
Interview tip → Say you treat stickiness as a stop-gap and push for stateless sessions.
More on Services, Ingress and DNS
A Service has no endpoints. How do you find out why?BeginnerWhen do you use ClusterIP, NodePort, LoadBalancer and ExternalName?BeginnerTraffic to a Service works from some pods but times out from others. How do you debug it?AdvancedYou want to expose three HTTP services under one hostname with different paths. How?Intermediateingress-nginx returns 404 for a new host. What do you check?Intermediateingress-nginx returns 502 or 503 intermittently. What are the likely reasons?Intermediate