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

Expose referSameObject function #2989

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

Expose referSameObject function #2989

keeganwitt opened this issue Oct 19, 2024 · 3 comments

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
@k8s-triage-robot
Copy link

The Kubernetes project currently lacks enough contributors to adequately respond to all issues.

This bot triages un-triaged issues according to the following rules:

  • After 90d of inactivity, lifecycle/stale is applied
  • After 30d of inactivity since lifecycle/stale was applied, lifecycle/rotten is applied
  • After 30d of inactivity since lifecycle/rotten was applied, the issue is closed

You can:

  • Mark this issue as fresh with /remove-lifecycle stale
  • Close this issue with /close
  • Offer to help out with Issue Triage

Please send feedback to sig-contributor-experience at kubernetes/community.

/lifecycle stale

@k8s-ci-robot k8s-ci-robot added the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 17, 2025
@keeganwitt
Copy link
Author

keeganwitt commented Jan 22, 2025

After the discussions in #2991, I think a better solution for the problem that spawned this issue is to expose the referSameObject() function (and possibly indexOwnerRef() too) which can be used for this and other use cases.

@keeganwitt keeganwitt changed the title Provide a function in controllerutil to add OwnerReferences to an object Expose referSameObject function Jan 22, 2025
@keeganwitt
Copy link
Author

/remove-lifecycle stale

@k8s-ci-robot k8s-ci-robot removed the lifecycle/stale Denotes an issue or PR has remained open with no activity and has become stale. label Jan 22, 2025
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

3 participants