-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Setting custom labels via PodTemplate.metadata.labels doesn't work #575
Comments
Killing pods is not the correct way as cass-operator does not itself recreate the pods, the StatefulSet controller does. The StatefulSet should get updated first (and should have the labels) and then that one will apply the pods. That said, Kubernetes itself prevents changing the metadata of PodTemplateSpec in StatefulSets, so this will require a bit of trickery. You need to delete the StatefulSet to get those changes applied:
The cascade is important, otherwise Kubernetes will delete all the pods. |
@burmanm Thank you for a workaround. |
Yeah, I must add at some point the limitations of StatefulSets in some docs (such as PVC changes & these metadata and few other fields). It's only vaguely mentioned in the Kubernetes docs if one understand the basics: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#pod-selector (the label change prevention is tied to the selector). The annotations are allowed to be modified. |
You are right, but the doc doesn't say that
This is a result:
As you can see it isn't necessary to have the same set of labels. |
Also, if you run the next command to patch the statefulset:
And it works well:
|
@burmanm Hello. Any updates here? |
Not really, the only ticket I found from Kubernetes is that it shouldn't work which makes me wonder if there's a difference between different Kubernetes versions or if the merge strategy is different in our client (but I don't have time today to test that). We don't have different code for annotations and labels processing in PodTemplateSpec (so we would apply those changes the same way). So for whatever reason the Kubernetes didn't pick up the change. |
Ok. Thank you for your reply. |
What happened?
We are trying to set custom pod labels to inject Istio-sidecar into Cassandra's pods.
This is our CassandraDatacenter manifest:
However, label isn't set.
We tried to manually kill pods, but it didn't help. Pods have only default labels.
Setting custom annotations via
podTemplateSpec
works well at the same time.What did you expect to happen?
Our extra label is set to Cassandra pods
How can we reproduce it (as minimally and precisely as possible)?
Apply the manifest above
cass-operator version
1.12
Kubernetes version
v1.26.5-gke.2100
Method of installation
Kustomize
Anything else we need to know?
No response
The text was updated successfully, but these errors were encountered: