A team deploys a microservice that requires sticky sessions. The service runs on Kubernetes with multiple replicas. Which Kubernetes resource should be used to ensure requests from a client are consistently routed to the same pod?
Trap 1: Headless Service
Headless services are for pod discovery, not load balancing with stickiness.
Trap 2: Ingress with default settings
Ingress without session affinity annotation does not maintain stickiness.
Trap 3: Deployment with hostNetwork: true
hostNetwork does not provide session affinity.
- A
Headless Service
Why wrong: Headless services are for pod discovery, not load balancing with stickiness.
- B
Service with sessionAffinity: ClientIP
This configuration ensures requests from the same client IP go to the same pod.
- C
Ingress with default settings
Why wrong: Ingress without session affinity annotation does not maintain stickiness.
- D
Deployment with hostNetwork: true
Why wrong: hostNetwork does not provide session affinity.