Debug: selector does not match template labels

Adler @ 2018-07-23


When using kubernetes-deploy, sometimes an error message pops up saying:

Deployment.apps "worker" is invalid: spec.template.metadata.labels: Invalid value: map[string]string{"app":"sidekiq", "function":"worker", "image":"bert"}: `selector` does not match template `labels`

Ususally it happens when we change the labels in deployment:

  template:
    metadata:
      labels:
        app: puma
        function: web
        image: bert
    spec:

In that case we'll need to delete the existing deployment and deploy a new one with these new labels.