P Ekambaram
P Ekambaram

Reputation: 17689

I want to add/remove a label from all pods running in a given namespace

Using the below command labels can be added to a pod.

kubectl label pod <pod-name> {key1=value1,key2=value2,key3=value3}

What is the best way to add or remove a label, say, [ env: dev ] from all pods running in a given namespace.

Upvotes: 0

Views: 2524

Answers (1)

gohm&#39;c
gohm&#39;c

Reputation: 15548

...to add or remove a label, say, [ env: dev ] from all pods running in a given namespace.

Try:

kubectl label pods --namespace <name> --all env=dev # <-- add

kubectl label pods --namespace <name> --all env- # <-- remove

Upvotes: 1

Related Questions