Error: selector does not match template labels
My task is to add a label named "app" to all deployments
, daemonsets
, and cronjobs
so that it's easier to query our apps across the stack in our monitoring tools. This way, we can build dashboards that use a single selector, namely app.
To avoid downtime I've decided to resolve this issue in the following steps:
- Add labels to dev, test & stage environments.
- Add labels to prod env's.
- Deploy (1)
- Deploy (2)
- Delete old labels & update the services of dev to use the new labels. Then test & deploy. (currently on this step)
- Repeat (5) for stage.
- Repeat (5) for prod.
When using $ kubectl apply
to update the resources I've added the "app" label to/replaced "service" label with "app" labels to, I run into the following error:
Error from server (Invalid): error when applying patch:
{longAssPatchWhichIWon'tIncludeButYaGetThePoint} to: &{0xc421b02f00
0xc420803650 default provisioning
manifests/prod/provisioning-deployment.yaml 0xc 42000c6f8 3942200
false} for: "manifests/prod/provisioning-deployment.yaml":
Deployment.apps "provisioning" is invalid: s
pec.template.metadata.labels: Invalid value:
map[string]string{"app":"provisioning", "component" :"marketplace"}:
selector
does not match templatelabels
I need some insights on why it's throwing this error.
kubernetes yaml
add a comment |
My task is to add a label named "app" to all deployments
, daemonsets
, and cronjobs
so that it's easier to query our apps across the stack in our monitoring tools. This way, we can build dashboards that use a single selector, namely app.
To avoid downtime I've decided to resolve this issue in the following steps:
- Add labels to dev, test & stage environments.
- Add labels to prod env's.
- Deploy (1)
- Deploy (2)
- Delete old labels & update the services of dev to use the new labels. Then test & deploy. (currently on this step)
- Repeat (5) for stage.
- Repeat (5) for prod.
When using $ kubectl apply
to update the resources I've added the "app" label to/replaced "service" label with "app" labels to, I run into the following error:
Error from server (Invalid): error when applying patch:
{longAssPatchWhichIWon'tIncludeButYaGetThePoint} to: &{0xc421b02f00
0xc420803650 default provisioning
manifests/prod/provisioning-deployment.yaml 0xc 42000c6f8 3942200
false} for: "manifests/prod/provisioning-deployment.yaml":
Deployment.apps "provisioning" is invalid: s
pec.template.metadata.labels: Invalid value:
map[string]string{"app":"provisioning", "component" :"marketplace"}:
selector
does not match templatelabels
I need some insights on why it's throwing this error.
kubernetes yaml
Can you share yaml for the deployment? One quick reminder, your deployment'sspec.selector
has to match labels ofspec.template.metadata.labels
.
– Emruz Hossain
Nov 14 '18 at 16:43
@EmruzHossain I understand but even after that update I still received the same error. I've included my .yaml file.
– v1mg1rl
Nov 14 '18 at 17:20
You should insert your code or manifests or something like to your problem description instead of inserting them by link
– Shudipta Sharma
Nov 14 '18 at 17:29
Correct your indentation inspec.selector.matchLabels
,spec.selector.matchLabels.app
andspec.selector.matchLabels.component
. You have used 4 spaces instead of 2 spaces.
– Shudipta Sharma
Nov 14 '18 at 17:37
add a comment |
My task is to add a label named "app" to all deployments
, daemonsets
, and cronjobs
so that it's easier to query our apps across the stack in our monitoring tools. This way, we can build dashboards that use a single selector, namely app.
To avoid downtime I've decided to resolve this issue in the following steps:
- Add labels to dev, test & stage environments.
- Add labels to prod env's.
- Deploy (1)
- Deploy (2)
- Delete old labels & update the services of dev to use the new labels. Then test & deploy. (currently on this step)
- Repeat (5) for stage.
- Repeat (5) for prod.
When using $ kubectl apply
to update the resources I've added the "app" label to/replaced "service" label with "app" labels to, I run into the following error:
Error from server (Invalid): error when applying patch:
{longAssPatchWhichIWon'tIncludeButYaGetThePoint} to: &{0xc421b02f00
0xc420803650 default provisioning
manifests/prod/provisioning-deployment.yaml 0xc 42000c6f8 3942200
false} for: "manifests/prod/provisioning-deployment.yaml":
Deployment.apps "provisioning" is invalid: s
pec.template.metadata.labels: Invalid value:
map[string]string{"app":"provisioning", "component" :"marketplace"}:
selector
does not match templatelabels
I need some insights on why it's throwing this error.
kubernetes yaml
My task is to add a label named "app" to all deployments
, daemonsets
, and cronjobs
so that it's easier to query our apps across the stack in our monitoring tools. This way, we can build dashboards that use a single selector, namely app.
To avoid downtime I've decided to resolve this issue in the following steps:
- Add labels to dev, test & stage environments.
- Add labels to prod env's.
- Deploy (1)
- Deploy (2)
- Delete old labels & update the services of dev to use the new labels. Then test & deploy. (currently on this step)
- Repeat (5) for stage.
- Repeat (5) for prod.
When using $ kubectl apply
to update the resources I've added the "app" label to/replaced "service" label with "app" labels to, I run into the following error:
Error from server (Invalid): error when applying patch:
{longAssPatchWhichIWon'tIncludeButYaGetThePoint} to: &{0xc421b02f00
0xc420803650 default provisioning
manifests/prod/provisioning-deployment.yaml 0xc 42000c6f8 3942200
false} for: "manifests/prod/provisioning-deployment.yaml":
Deployment.apps "provisioning" is invalid: s
pec.template.metadata.labels: Invalid value:
map[string]string{"app":"provisioning", "component" :"marketplace"}:
selector
does not match templatelabels
I need some insights on why it's throwing this error.
kubernetes yaml
kubernetes yaml
edited Nov 19 '18 at 14:14
asked Nov 14 '18 at 16:12
v1mg1rl
358
358
Can you share yaml for the deployment? One quick reminder, your deployment'sspec.selector
has to match labels ofspec.template.metadata.labels
.
– Emruz Hossain
Nov 14 '18 at 16:43
@EmruzHossain I understand but even after that update I still received the same error. I've included my .yaml file.
– v1mg1rl
Nov 14 '18 at 17:20
You should insert your code or manifests or something like to your problem description instead of inserting them by link
– Shudipta Sharma
Nov 14 '18 at 17:29
Correct your indentation inspec.selector.matchLabels
,spec.selector.matchLabels.app
andspec.selector.matchLabels.component
. You have used 4 spaces instead of 2 spaces.
– Shudipta Sharma
Nov 14 '18 at 17:37
add a comment |
Can you share yaml for the deployment? One quick reminder, your deployment'sspec.selector
has to match labels ofspec.template.metadata.labels
.
– Emruz Hossain
Nov 14 '18 at 16:43
@EmruzHossain I understand but even after that update I still received the same error. I've included my .yaml file.
– v1mg1rl
Nov 14 '18 at 17:20
You should insert your code or manifests or something like to your problem description instead of inserting them by link
– Shudipta Sharma
Nov 14 '18 at 17:29
Correct your indentation inspec.selector.matchLabels
,spec.selector.matchLabels.app
andspec.selector.matchLabels.component
. You have used 4 spaces instead of 2 spaces.
– Shudipta Sharma
Nov 14 '18 at 17:37
Can you share yaml for the deployment? One quick reminder, your deployment's
spec.selector
has to match labels of spec.template.metadata.labels
.– Emruz Hossain
Nov 14 '18 at 16:43
Can you share yaml for the deployment? One quick reminder, your deployment's
spec.selector
has to match labels of spec.template.metadata.labels
.– Emruz Hossain
Nov 14 '18 at 16:43
@EmruzHossain I understand but even after that update I still received the same error. I've included my .yaml file.
– v1mg1rl
Nov 14 '18 at 17:20
@EmruzHossain I understand but even after that update I still received the same error. I've included my .yaml file.
– v1mg1rl
Nov 14 '18 at 17:20
You should insert your code or manifests or something like to your problem description instead of inserting them by link
– Shudipta Sharma
Nov 14 '18 at 17:29
You should insert your code or manifests or something like to your problem description instead of inserting them by link
– Shudipta Sharma
Nov 14 '18 at 17:29
Correct your indentation in
spec.selector.matchLabels
, spec.selector.matchLabels.app
and spec.selector.matchLabels.component
. You have used 4 spaces instead of 2 spaces.– Shudipta Sharma
Nov 14 '18 at 17:37
Correct your indentation in
spec.selector.matchLabels
, spec.selector.matchLabels.app
and spec.selector.matchLabels.component
. You have used 4 spaces instead of 2 spaces.– Shudipta Sharma
Nov 14 '18 at 17:37
add a comment |
1 Answer
1
active
oldest
votes
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.
The API version I have for that file is extension/v1beta1. So I should be able to change/update the selector right?
– v1mg1rl
Nov 14 '18 at 20:15
Theoretically, yes. I haven't tried. You have readLabel selector updates
section I have linked in my answer, right? There are some problem in changingselector
. Old ReplicaSet will be orphaned. Also, be sure that your deployment isextension/v1beta1
api version.kubectl
will always returnextension
api group even if your deployment isapps/v1
. Ref: github.com/kubernetes/kubernetes/issues/…
– Emruz Hossain
Nov 15 '18 at 3:28
add a comment |
Your Answer
StackExchange.ifUsing("editor", function () {
StackExchange.using("externalEditor", function () {
StackExchange.using("snippets", function () {
StackExchange.snippets.init();
});
});
}, "code-snippets");
StackExchange.ready(function() {
var channelOptions = {
tags: "".split(" "),
id: "1"
};
initTagRenderer("".split(" "), "".split(" "), channelOptions);
StackExchange.using("externalEditor", function() {
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled) {
StackExchange.using("snippets", function() {
createEditor();
});
}
else {
createEditor();
}
});
function createEditor() {
StackExchange.prepareEditor({
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: true,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: 10,
bindNavPrevention: true,
postfix: "",
imageUploader: {
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
},
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304461%2ferror-selector-does-not-match-template-labels%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
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.
The API version I have for that file is extension/v1beta1. So I should be able to change/update the selector right?
– v1mg1rl
Nov 14 '18 at 20:15
Theoretically, yes. I haven't tried. You have readLabel selector updates
section I have linked in my answer, right? There are some problem in changingselector
. Old ReplicaSet will be orphaned. Also, be sure that your deployment isextension/v1beta1
api version.kubectl
will always returnextension
api group even if your deployment isapps/v1
. Ref: github.com/kubernetes/kubernetes/issues/…
– Emruz Hossain
Nov 15 '18 at 3:28
add a comment |
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.
The API version I have for that file is extension/v1beta1. So I should be able to change/update the selector right?
– v1mg1rl
Nov 14 '18 at 20:15
Theoretically, yes. I haven't tried. You have readLabel selector updates
section I have linked in my answer, right? There are some problem in changingselector
. Old ReplicaSet will be orphaned. Also, be sure that your deployment isextension/v1beta1
api version.kubectl
will always returnextension
api group even if your deployment isapps/v1
. Ref: github.com/kubernetes/kubernetes/issues/…
– Emruz Hossain
Nov 15 '18 at 3:28
add a comment |
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.
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.
answered Nov 14 '18 at 18:27
Emruz Hossain
1,084210
1,084210
The API version I have for that file is extension/v1beta1. So I should be able to change/update the selector right?
– v1mg1rl
Nov 14 '18 at 20:15
Theoretically, yes. I haven't tried. You have readLabel selector updates
section I have linked in my answer, right? There are some problem in changingselector
. Old ReplicaSet will be orphaned. Also, be sure that your deployment isextension/v1beta1
api version.kubectl
will always returnextension
api group even if your deployment isapps/v1
. Ref: github.com/kubernetes/kubernetes/issues/…
– Emruz Hossain
Nov 15 '18 at 3:28
add a comment |
The API version I have for that file is extension/v1beta1. So I should be able to change/update the selector right?
– v1mg1rl
Nov 14 '18 at 20:15
Theoretically, yes. I haven't tried. You have readLabel selector updates
section I have linked in my answer, right? There are some problem in changingselector
. Old ReplicaSet will be orphaned. Also, be sure that your deployment isextension/v1beta1
api version.kubectl
will always returnextension
api group even if your deployment isapps/v1
. Ref: github.com/kubernetes/kubernetes/issues/…
– Emruz Hossain
Nov 15 '18 at 3:28
The API version I have for that file is extension/v1beta1. So I should be able to change/update the selector right?
– v1mg1rl
Nov 14 '18 at 20:15
The API version I have for that file is extension/v1beta1. So I should be able to change/update the selector right?
– v1mg1rl
Nov 14 '18 at 20:15
Theoretically, yes. I haven't tried. You have read
Label selector updates
section I have linked in my answer, right? There are some problem in changing selector
. Old ReplicaSet will be orphaned. Also, be sure that your deployment is extension/v1beta1
api version. kubectl
will always return extension
api group even if your deployment is apps/v1
. Ref: github.com/kubernetes/kubernetes/issues/…– Emruz Hossain
Nov 15 '18 at 3:28
Theoretically, yes. I haven't tried. You have read
Label selector updates
section I have linked in my answer, right? There are some problem in changing selector
. Old ReplicaSet will be orphaned. Also, be sure that your deployment is extension/v1beta1
api version. kubectl
will always return extension
api group even if your deployment is apps/v1
. Ref: github.com/kubernetes/kubernetes/issues/…– Emruz Hossain
Nov 15 '18 at 3:28
add a comment |
Thanks for contributing an answer to Stack Overflow!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53304461%2ferror-selector-does-not-match-template-labels%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Can you share yaml for the deployment? One quick reminder, your deployment's
spec.selector
has to match labels ofspec.template.metadata.labels
.– Emruz Hossain
Nov 14 '18 at 16:43
@EmruzHossain I understand but even after that update I still received the same error. I've included my .yaml file.
– v1mg1rl
Nov 14 '18 at 17:20
You should insert your code or manifests or something like to your problem description instead of inserting them by link
– Shudipta Sharma
Nov 14 '18 at 17:29
Correct your indentation in
spec.selector.matchLabels
,spec.selector.matchLabels.app
andspec.selector.matchLabels.component
. You have used 4 spaces instead of 2 spaces.– Shudipta Sharma
Nov 14 '18 at 17:37