Error: selector does not match template labels
It seems you are in trouble. Check this section: Label selector updates
Note: In API version
apps/v1
, a Deployment’s label selector is immutable after it gets created.
So, this line say you can not update selector
once deployment is created. Selector can not be changed for any API version except apps/v1beta1
and extension/v1beta1
. Ref: TestDeploymentSelectorImmutability.
One possible workaround might be to keep the old labels and adding new labels along with old ones. This way, you don't have to update selector
. Deployment will select pods using old labels but your dashboard can select using new labels. This might not meet your requirement but I don't see any better way.
This error is hard to read but it means that the labels specified in spec.template.metadata.labels of your Deployment definition do not match those of spec.selector.matchLabels within the same definition. Upload your YAML if you require further assistance. Best!
There are a few ways to resolve this from what I can tell. One way is to delete the deployment and re-apply the deployment with a key/value that works on your deployment:
spec: selector: matchLabels: app: app_name template: metadata: labels: app: app_name -- whatever else --
This obviously incurs downtime but should be permanent. Your other option is to edit the deployment selector:
kubectl -n namespace edit deployment app-deployment
Then run your apply command again. This may or may not be permanent as I don't know what changed the selector to begin with.
If your pod doesn't even exist yet to do modifications, this error might be legit. You may have a pod with the same name in the same namespace.