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

Time:08-04

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.

CodePudding user response:

...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

  • Related