A label is a key-value annotation added to a Kubernetes resource’s metadata. Labels identify resources and let kubectl filter them; Services also use matching labels to find and attach to Pods. section 8.3.2
Apply labels in a manifest, then query matching resources with a selector:
- kubectl get pods -l app=my-nginx section 8.3.2
- kubectl get pods --selector app=my-nginx section 8.3.2
- kubectl get services -l app=my-nginx section 8.3.2
Connecting an NGINX Pod to a Service
Add app: my-nginx under the Pod manifest’s metadata, apply the updated manifest with kubectl apply, and verify it with kubectl get pods my-nginx -o yaml. A Service using selector app: my-nginx can then find the labeled Pod. section 8.3.2






