Networking
medium

Questão de Networking #019e3a4f

Enunciado da Questão
Networking
#kubernetes
#headless-service
#statefulset
Médio

Which of the following workload require a headless service while deploying into the namespace?

A

StatefulSet

Correta
B

CronJob

C

Deployment

D

DaemonSet

Explicação Oficial / Explicações da Comunidade

A headless service is required for StatefulSets because StatefulSets manage stateful applications that require stable network identities. A headless service (with clusterIP: None) allows direct pod-to-pod communication without load balancing, enabling each pod to have a unique DNS name (e.g., pod-name.service-name.namespace.svc.cluster.local). This is essential for StatefulSets where each pod must be individually addressable, such as in databases like Cassandra or ZooKeeper.

How it Works:

  • A headless service does not allocate a cluster IP; instead, DNS returns the pod IPs directly.
  • StatefulSets use headless services to maintain stable network identities for each pod, which persist across rescheduling.
  • Other workloads like Deployments, DaemonSets, and CronJobs do not require stable network identities; they use regular ClusterIP services for load-balanced access.

Why the correct value is right:

  • StatefulSet requires a headless service to provide stable, unique network identities for each pod. Without it, pods would not have predictable DNS names, breaking stateful applications.

Why the incorrect values are wrong:

  • CronJob: Manages batch jobs on a schedule; pods are ephemeral and do not need stable network identities. A regular service or no service is sufficient.
  • Deployment: Manages stateless replicas; pods are interchangeable and do not require unique identities. A ClusterIP service provides load balancing.
  • DaemonSet: Ensures one pod per node; pods are typically used for monitoring or logging and do not require stable network identities. A headless service is not needed.