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