Network and Headless Services
Let's explore headless Service using an example.
We'll cover the following
We’ve already said that StatefulSets are for applications that need Pods to be predictable and long-lived. This might involve applications connecting to specific Pods rather than letting the Service perform round-robin load balancing across all Pods. To make this possible, StatefulSets use a headless Service to create reliable and predictable DNS names for every Pod. Other apps can then query DNS (the service registry) for the full list of Pods and make direct connections.
Defining a headless Service
The following YAML snippet shows a headless Service called mongo-prod listed in the StatefulSet YAML as the governing Service.
Get hands-on with 1400+ tech skills courses.