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

Provide a function in controllerutil to add OwnerReferences to an object #2989

Open
keeganwitt opened this issue Oct 19, 2024 · 0 comments
Open

Comments

@keeganwitt
Copy link

If you are creating a new object, you may need a function to tie this new object to the lifecycle of the owners of the object being reconciled. For example, I have a controller that reconciles pods, which is writing secrets for the pods to use. In the case of a standalone pod, it's fine to just set the pod as an owner of this new secret using controllerutil.SetOwnerReference(). However, for pods which have an owner (ReplicaSets, DaemonSets, etc), the secret may be shared with all other related pods, as they are members of the same workload. This requires me to duplicate the logic of controllerutil.upsertOwnerRef() in my project, since I don't have the objects referred to by the pod's ownerReferences, only the references themselves and that function is not public. It would be useful in such cases to either make controllerutil.upsertOwnerRef() public, or expose that function through a new public function. If we add the ability to add an OwnerReference in this way, we should probably also add the ability to remove it as well.

keeganwitt added a commit to keeganwitt/kubernetes-controller-runtime that referenced this issue Oct 19, 2024
keeganwitt added a commit to keeganwitt/kubernetes-controller-runtime that referenced this issue Oct 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant