Kubernetes not able to add label to pod

8/22/2016

I am unable to add a label to my kubernetes pod. Why is this not working?

$ kubectl describe pods secure-monolith | grep Label
Labels:     app=monolith 

$ kubectl label pods secure-monolith "secure=enabled"
pod "secure-monolith" labeled

$ kubectl describe pods secure-monolith | grep Label
Labels:     app=monolith

$ kubectl label pods secure-monolith "secure=enabled"
'secure' already has a value (enabled), and --overwrite is false

As you can see, it says the label was successfully added, however the label does not appear when "describing" the pod; and it can also not be added again.

-- Nicky Feller
kubernetes

1 Answer

8/22/2016

You are grepping through the describe output, but only the first line of labels description contains Label string.

Labels output for two labels looks as follows:

Labels:         a=b
                c=d

So secure=enabled is there, you just filtered it out.

-- Nebril
Source: StackOverflow