2023-12-14 12:11:19 +00:00
|
|
|
# kubectl label
|
2023-10-20 05:10:26 +01:00
|
|
|
|
2023-12-14 12:11:19 +00:00
|
|
|
> Label Kubernetes resources.
|
2023-10-20 05:10:26 +01:00
|
|
|
> More information: <https://kubernetes.io/docs/reference/generated/kubectl/kubectl-commands#label>.
|
|
|
|
|
|
|
|
- Label a pod:
|
|
|
|
|
|
|
|
`kubectl label pod {{pod_name}} {{key}}={{value}}`
|
|
|
|
|
|
|
|
- Update a pod label by overwriting the existing value:
|
|
|
|
|
2024-05-25 17:06:04 +01:00
|
|
|
`kubectl label --overwrite pod {{pod_name}} {{key}}={{value}}`
|
2023-10-20 05:10:26 +01:00
|
|
|
|
|
|
|
- Label all pods in the namespace:
|
|
|
|
|
|
|
|
`kubectl label pods --all {{key}}={{value}}`
|
|
|
|
|
2024-05-25 17:06:04 +01:00
|
|
|
- Label a pod identified by the pod definition file:
|
2023-10-20 05:10:26 +01:00
|
|
|
|
2024-05-25 17:06:04 +01:00
|
|
|
`kubectl label -f {{pod_definition_file}} {{key}}={{value}}`
|
2023-10-20 05:10:26 +01:00
|
|
|
|
|
|
|
- Remove the label from a pod:
|
|
|
|
|
|
|
|
`kubectl label pod {{pod_name}} {{key}}-`
|