Step 01 of 06
Learn the concept
Pod IPs are mayflies. A Service is the name you can print in documentation without apologizing tomorrow. The wiring is just labels, which is comforting until one label is wrong.
The ideas this is made of
A Service is stable addressing over unstable Pods
Pods get IP addresses, but those addresses are disposable. A restart, reschedule or rollout creates new Pods with new IPs. A ClusterIP Service provides one stable virtual IP and DNS name inside the cluster. Traffic sent to the Service is load-balanced to the current endpoints selected by labels. The Service is not the process; it is the address and routing rule.
Selectors are the actual wiring
A Service does not point to a Deployment by name. It selects Pods whose labels match its selector. If the Deployment template label is app.kubernetes.io/name: beacon and the Service selector says the same, endpoints appear. If one character differs, the Service exists but has no backends. That failure is quiet until you inspect Endpoints or EndpointSlices.
CoreDNS turns Services into names
Inside the cluster, CoreDNS answers names like beacon.beacon.svc.cluster.local. The shorter beacon may work from the same namespace because search paths are added. The full name explains the pieces: service name, namespace, service zone and cluster domain. DNS gives clients a stable string; EndpointSlices keep that string connected to changing Pods.
port and targetPort are different promises
port is the port clients use on the Service. targetPort is the port on the selected Pod. They can be the same number, and often are, but they are not the same field. Naming the container port http and setting targetPort: http avoids mismatches when a container port changes later.
mail to: box 42
current tenants: unit 3A, unit 7C
move-out: unit 3A
move-in: unit 9B
mail still goes to box 42The Service is the box number. EndpointSlices are the current tenant list. Nobody should mail a Pod IP directly unless they enjoy forwarding addresses as a lifestyle.
Service fields people confuse
| Field | Means | Beacon value |
|---|---|---|
| DNS service name |
|
| Client-facing port |
|
| Pod container port |
|
| Pod label query |
|
| Internal virtual IP | Assigned by cluster |
What these are called on the job
ClusterIP — The default Service type: a stable virtual IP reachable inside the cluster.
EndpointSlice — A scalable object listing the current backend addresses for a Service.
CoreDNS — The cluster DNS service that resolves Kubernetes service names.
Headless Service — A Service with
clusterIP: Nonethat returns endpoint addresses directly, useful for stable identities.
