The Label Trap: Why Your Service Has No Endpoints
Stop copying YAML blindly. Learn how Kubernetes objects chain together via labels and selectors, and use kubectl commands to debug the most common deployment failure.

Most new homelab operators size their cluster for the apps they want to run today. That is the trap. A Deployment looks correct in a README, it applies without error, and the pod appears healthy. Nothing about it looks wrong until you try to reach the app from outside the cluster, and the request fails with no error anywhere obvious.
The book Kubernetes Without the Overwhelm opens its first chapter with exactly this, under a heading that sums it up: learn the chain. This post covers the object chain behind every app, how labels connect them, and the exact kubectl commands to find where the link is missing.
One caveat, straight from the book: this is general guidance for running apps in Kubernetes. Your specific application may require different resources or configurations, so check the documentation for that app, and ask a community forum if anything looks off.
The rule: objects point by name or label
The core idea of Kubernetes is that every object has exactly one job and points at the next one. You almost never create pods directly. You create a Deployment, and the Deployment creates a ReplicaSet, which creates pods. If a pod dies, or the node under it dies, the ReplicaSet notices the count is short and creates a replacement somewhere else. That is the control loop in its simplest form.
The chain of objects behind one app works like this: a Deployment keeps a ReplicaSet at the right size, the ReplicaSet keeps pods running, a Service gives the pods one stable address by matching their labels, an Ingress maps a hostname to the Service, and a PersistentVolumeClaim asks for storage that the pod mounts.
| Object | Its one job |
|---|---|
| Pod | One or more containers that share a network address and volumes; the unit the scheduler places |
| Deployment | Keeps N identical, replaceable pods running and rolls out new versions gradually |
| Service | A stable virtual IP and DNS name in front of a set of pods, chosen by labels |
| Ingress | Routes HTTP(S) by hostname and path to Services, through an ingress controller |
The trap: waiting for the pod to tell you
The usual way people find out a Service is broken is that they get a connection refused error. The book's answer is to check the labels instead. Objects do not reference pods by name, because pod names change every time one is replaced. They use labels (key-value pairs on the object) and selectors (queries over labels).
If the Service selector and the pod labels do not match exactly, the Service has no endpoints and every request fails. A typo in a label is the most common reason a freshly deployed app "does not work". The app.kubernetes.io/name key is one of the recommended labels in the Kubernetes documentation; any consistent scheme works, but use one scheme everywhere.
You can see this chain in action with a simple test app. The book provides a complete example for the traefik/whoami image, which prints details of each request. Notice how the Deployment template sets the label, and the Service selector matches it exactly.
apiVersion: apps/v1
kind: Deployment
metadata:
name: whoami
namespace: whoami
spec:
replicas: 2
selector:
matchLabels:
app.kubernetes.io/name: whoami
template:
metadata:
labels:
app.kubernetes.io/name: whoami
spec:
containers:
- name: whoami
image: traefik/whoami
ports:
- containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
name: whoami
namespace: whoami
spec:
selector:
app.kubernetes.io/name: whoami
ports:
- port: 80
targetPort: 80
If you change the label in the Deployment but forget to update the Service, or vice versa, the chain breaks. The pod runs fine, but the Service has nothing to route to. You cannot fix this by restarting the pod; you must fix the YAML so the selector matches the label.
The fix: follow the chain with kubectl
You do not need to guess which object is failing. Kubernetes provides a small set of commands that answer almost every question about the state of your cluster. Once you see how they connect, the rest are variations on the same idea.
Start by checking what is running and where it is ready. Use get pods with the -n NS flag to target the correct namespace. The book notes this answers: "What is running, where, and is it ready?".
kubectl get pods -n NS
If a pod is not running, or if you suspect the Service is not finding it, use describe. This command shows the events at the bottom of the output, which often contain the reason for failure. The book notes this answers: "Why is it not running?".
kubectl describe pod NAME -n NS
To see what your application is actually doing, check its logs. Use --previous if you suspect a crash loop and want to see the output from the last container instance before it restarted. The book notes this answers: "What did the app print?".
kubectl logs NAME -n NS
When you are editing files, never just apply them blindly. Run diff first to see exactly what changes will be made. This prevents accidental deletions or misconfigurations. The book advises: "Run it before every apply".
kubectl diff -f file.yaml
Once you are sure the YAML is correct, apply it. The API server works out what to change based on the desired state in your file. The book states this command creates or updates the objects in a file.
kubectl apply -f file.yaml
If you want to see all the objects for your app at once, use get with multiple resource types. This confirms that the Deployment, Service, and Ingress all exist in the correct namespace. The book provides this specific command to check the status of these four object types together.
kubectl get deploy,pods,svc,ingress -n whoami
Namespaces keep things readable
Namespaces split the cluster into named areas. The book recommends giving each of your apps its own namespace too. It keeps kubectl get output readable, lets you delete an app and everything with it in one command, and is the boundary NetworkPolicies and resource quotas work on.
Create a namespace for your app before deploying anything else. Then run commands with the -n flag to target that specific area. You can also view every namespace in the cluster using the -A flag. The book provides these exact commands for managing namespaces.
kubectl create namespace whoami
kubectl get pods -n whoami
kubectl get pods -A # every namespace
Checklist
- [ ] Verify your Deployment template has a label under
metadata.labels. - [ ] Verify your Service selector matches that label exactly under
spec.selector. - [ ] Run
kubectl get pods -n NSto confirm pods are in the Ready state. - [ ] Run
kubectl describe pod NAME -n NSif a pod is stuck in Pending or Error. - [ ] Run
kubectl logs NAME -n NSto check application output for clues. - [ ] Use
kubectl diff -f file.yamlbefore applying any new configuration. - [ ] Apply changes with
kubectl apply -f file.yamlrather than imperative commands. - [ ] Keep your YAML files in version control, not just in your terminal history.