Bird
0
0

You want to deploy a stateful app that requires direct pod access and custom load balancing. Which Kubernetes service setup is best?

hard📝 Best Practice Q15 of 15
Kubernetes - Services
You want to deploy a stateful app that requires direct pod access and custom load balancing. Which Kubernetes service setup is best?
ACreate a ClusterIP service with externalTrafficPolicy set to Local
BUse a LoadBalancer service with multiple replicas
CUse a NodePort service with a Deployment
DCreate a headless service with clusterIP: None and use StatefulSet pods
Step-by-Step Solution
Solution:
  1. Step 1: Understand requirements for stateful apps

    Stateful apps often need stable network IDs and direct pod access for custom load balancing.
  2. Step 2: Match Kubernetes service type to requirements

    Headless services (clusterIP: None) combined with StatefulSets provide stable pod identities and direct access.
  3. Step 3: Evaluate other options

    LoadBalancer and NodePort services use load balancing and do not provide stable pod DNS; ClusterIP with externalTrafficPolicy affects routing but not pod identity.
  4. Final Answer:

    Create a headless service with clusterIP: None and use StatefulSet pods -> Option D
  5. Quick Check:

    Stateful + headless + StatefulSet = best fit [OK]
Quick Trick: StatefulSet + headless service = stable pod access [OK]
Common Mistakes:
  • Using LoadBalancer for stateful direct pod access
  • Confusing NodePort with headless service benefits
  • Ignoring StatefulSet for stable pod identities

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Kubernetes Quizzes