codegurukool.com · Free coding tutorials & online compiler

Home › Kubernetes Tutorial › Labels and selectors

Labels and selectors

Group and find objects.

Labels are key-value tags on objects, such as app: web or env: prod. Selectors pick objects by their labels. Services, Deployments and many kubectl commands use them. Use -l to filter.

Example code

kubectl get pods -l app=web

Run this code in the online editor

← Service types: ClusterIP, NodePort, LoadBalancerNamespaces →