2025-03-14 21:59:59 -06:00
|
|
|
# kubectl label
|
|
|
|
|
|
|
|
|
|
> Label Kubernetes resources.
|
2025-12-16 10:20:31 -07:00
|
|
|
> More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_label>.
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Label a pod:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Update a pod label by overwriting the existing value:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}} --overwrite`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Label all pods in the namespace:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl label {{[po|pods]}} {{key}}={{value}} --all`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Label a pod identified by the pod definition file:
|
|
|
|
|
|
2025-05-08 12:26:01 -06:00
|
|
|
`kubectl label {{[-f|--filename]}} {{pod_definition_file}} {{key}}={{value}}`
|
2025-03-14 21:59:59 -06:00
|
|
|
|
|
|
|
|
- Remove the label from a pod:
|
|
|
|
|
|
2025-12-16 10:20:31 -07:00
|
|
|
`kubectl label {{[po|pods]}} {{pod_name}} {{key}}-`
|