Updating a daemonset, but "`selector` does not match template `labels`"

1,457 views
Skip to first unread message

Nate Rook

unread,
Apr 11, 2017, 5:07:28 PM4/11/17
to Kubernetes user discussion and Q&A
So, I'm updating a daemonset to look like this:

apiVersion: extensions/v1beta1
kind: DaemonSet
metadata:
  name: sysdig-agent
spec:
  template:
    metadata:
      name: sysdig-agent
      labels:
        type: sysdig-agent
        class: infrastructure
        environment: staging
    spec:
      // ... 

But, I was surprised to get this error when I tried kubectl applying the update:

The DaemonSet "sysdig-agent" is invalid: spec.template.metadata.labels: Invalid value: {"class":"infrastructure","environment":"staging","type":"sysdig-agent"}: `selector` does not match template `labels`

I never actually created a selector, so I gather one is created implicitly. But I'm not sure what my implicit selector looks like, or why it disagrees with these labels.

I do see if I add a 'name' label to my pod template as well, everything works fine. But I'm not clear on why that is. Any ideas?

Matthias Rampke

unread,
Apr 12, 2017, 3:38:09 AM4/12/17
to Kubernetes user discussion and Q&A

If I recall correctly, the implicit selector is created from the daemonset metadata.

A daemonset needs a selector to function, so it knows which pods already exist. You are probably better off being explicit about it.

/MR


--
You received this message because you are subscribed to the Google Groups "Kubernetes user discussion and Q&A" group.
To unsubscribe from this group and stop receiving emails from it, send an email to kubernetes-use...@googlegroups.com.
To post to this group, send email to kubernet...@googlegroups.com.
Visit this group at https://groups.google.com/group/kubernetes-users.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages