DEV Community

Discussion on: Building a headless service in Kubernetes

Collapse
 
chukmunnlee profile image
chukmunnlee

Headless service is typically used with StatefulSets where the name of the pods are fixed. This is useful in situations like when you're settling up a MySQL cluster where you need to know the name of the master. StatefulSets appends an ordinal number to the name of the pod and it will always assign the same ordinal number of the pod is restarted or migrated by the scheduler.

In the case of a regular Deployment, ReplicaSet appends a hash to the pod's name making addressing specific pods difficult. The hash sort of anonomize the pods.

So if your application is stateless then you will just use with a 'regular' service because you don't care which pod you get. They're all the same.