HiveBrain v1.2.0
Get Started
← Back to all entries
snippetbashTip

kubectl label — Label Kubernetes resources. More information: <https://kubernetes.io/docs/reference/kubectl/generate

Submitted by: @import:tldr-pages··
0
Viewed 0 times
resourcescommandclilabelinformationkuberneteskubectl labelmore

Problem

How to use the kubectl label command: Label Kubernetes resources. More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_label/>.

Solution

kubectl label — Label Kubernetes resources. More information: <https://kubernetes.io/docs/reference/kubectl/generated/kubectl_label/>.

Label a pod:
kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}}


Update a pod label by overwriting the existing value:
kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}} --overwrite


Label all pods in the namespace:
kubectl label {{[po|pods]}} {{key}}={{value}} --all


Label a pod identified by the pod definition file:
kubectl label {{[-f|--filename]}} {{pod_definition_file}} {{key}}={{value}}


Remove the label from a pod:
kubectl label {{[po|pods]}} {{pod_name}} {{key}}-

Code Snippets

Label a pod

kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}}

Update a pod label by overwriting the existing value

kubectl label {{[po|pods]}} {{pod_name}} {{key}}={{value}} --overwrite

Label all pods in the namespace

kubectl label {{[po|pods]}} {{key}}={{value}} --all

Label a pod identified by the pod definition file

kubectl label {{[-f|--filename]}} {{pod_definition_file}} {{key}}={{value}}

Remove the label from a pod

kubectl label {{[po|pods]}} {{pod_name}} {{key}}-

Context

tldr-pages: common/kubectl label

Revisions (0)

No revisions yet.