Skip to content
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

K8SSAND-1052 ⁃ No options to add labels on the statefulset object #235

Closed
piclemx opened this issue Nov 16, 2021 · 9 comments · Fixed by #236
Closed

K8SSAND-1052 ⁃ No options to add labels on the statefulset object #235

piclemx opened this issue Nov 16, 2021 · 9 comments · Fixed by #236
Labels
enhancement New feature or request

Comments

@piclemx
Copy link
Contributor

piclemx commented Nov 16, 2021

What happened?
I trying to add labels to the statefulset because of our policy in our cluster. Does it possible currently with the operator?

I saw that we have podTemplateSpec and I added those. But seems to add it only on the pod not the statefulset object?

Did you expect to see something different?
Add the possibility to add the labels on all resources created.

How to reproduce it (as minimally and precisely as possible):

Environment

  • Cass Operator version:

    Insert image tag or Git SHA here

    * Kubernetes version information:docker.io/k8ssandra/cass-operator:v1.7.1

┆Issue is synchronized with this Jira Task by Unito
┆friendlyId: K8SSAND-1052
┆priority: Medium

@piclemx piclemx added the bug Something isn't working label Nov 16, 2021
@sync-by-unito sync-by-unito bot changed the title No options to add labels on the statefulset object K8SSAND-1052 ⁃ No options to add labels on the statefulset object Nov 16, 2021
@burmanm burmanm added enhancement New feature or request and removed bug Something isn't working labels Nov 17, 2021
@burmanm
Copy link
Contributor

burmanm commented Nov 17, 2021

There's currently no method to add user defined labels in the generated StatefulSet. podTemplateSpec only adds the details to the StatefulSet's podTemplateSpec which is why StatefulSet itself doesn't get added labels from there.

@piclemx
Copy link
Contributor Author

piclemx commented Nov 17, 2021

@burmanm I can add it if you want. What will be the best way to do it?

@jsanda
Copy link
Contributor

jsanda commented Nov 17, 2021

I was going to suggest a field like AdditionalLabels that would apply the labels not only to the StatefulSets but to all objects that the operator creates, but then I remembered we already have an AdditionalServiceConfig field for adding lables/annotations to services. Given that and if you only want to add labels to the StatefulSets then maybe something like AdditionalStatefulSetConfig.

@piclemx
Copy link
Contributor Author

piclemx commented Nov 17, 2021

@jsanda I prefer the first option I think IMO. Operator should always give the possibility to the user to add some labels. Often is related to the enterprise policy for tagging stuff.

I don't know what you think. Do you think we should used the v1.Object.Metadata? So if someone want to add not just labels but other metadata we will have the options.

@jsanda
Copy link
Contributor

jsanda commented Nov 17, 2021

I would create/use a struct that has the fields from ObjectMetadata that you want which I assume is primarily labels and maybe annotations.

@burmanm
Copy link
Contributor

burmanm commented Nov 17, 2021

Most likely the AdditionalLabels+AdditionalAnnotations type of struct would make more sense. That would be checked in the labels.go, AddKubernetesLabels and added there after the normal Kubernetes annotations. That would include those labels to every resource that cass-operator creates. It would also allow to override previous labels, such as app.kubernetes.io/name or instance if the user wanted.

@burmanm
Copy link
Contributor

burmanm commented Nov 17, 2021

Adding only to the StatefulSet sounds odd since it's not "external" in a sense, like the services in some cases are.

@piclemx
Copy link
Contributor Author

piclemx commented Nov 17, 2021

Yeah. I will try to open a PR today related to that.

@piclemx
Copy link
Contributor Author

piclemx commented Nov 17, 2021

@burmanm I'm talking about adding labels for everything that the operator creates.

Do you think I should add the AdditionalLabels and AdditionalAnnotations in the spec cassandradatacenter_types.go?

@piclemx piclemx mentioned this issue Nov 17, 2021
5 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants