This repository has been archived by the owner on Jun 20, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 49
Deployment's selector should be immutable #16
Comments
kupson
added a commit
to kupson/kube-libsonnet
that referenced
this issue
Mar 23, 2019
Fixes issue bitnami#16 - Deployment's selector should be immutable Scenario: - Deployment is created with kube.libsonnet, CI process adds additional labels e.g. "ci-job-id" - Deployment is updated with the same process but the CI process was updated to add new label e.g. "ci-cluster" - kubectl apply fails as the selector field is immutable This adds an additional label "app" to Pod, Deployment, StatefulSet, DaemonSet, Job and CronJob objects and use it when those objects needs to be referred by selectors.
kupson
added a commit
to rkwaysltd/k8slab-kube-libsonnet
that referenced
this issue
May 25, 2020
Example repository with workaround discussed in pull request #17 - https://github.com/rkwaysltd/k8slab-kube-libsonnet |
I'm doing something to allow labels to differ between the deployment itself and the pod template
my library is an overlay of bitnami's library. |
the bitnami library is technically doing this correctly, in that, the select points to the pod labels. Which matches the documentation.
https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#selector
The problem I found is that I needed a way to have the deployment labels differ from the pod labels. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Currently,
Deployment
'sselector
is populated based ondeployment.spec.template.metadata.labels
, which itself comes from thedeployment.metadata.labels
.This works fine as long as the
deployment.metadata.labels
are not modified between two deployments. In the other cases, it will raise animmutable field
error.https://github.com/bitnami-labs/kube-libsonnet/blob/master/kube.libsonnet#L385-L387
Ultimately, pod labels can have for a wider range of use-cases which should not be tight to the
Deployment
selector.An alternative approach would be to use a deterministic value to populate the the
deployment.spec.template.metadata.labels
andselector
(eg: I think thatksonnet-lib
uses the{app: metadata.name}
).The text was updated successfully, but these errors were encountered: