kube
kube copied to clipboard
Add generic helpers to kube-core
Lots of use cases for adding helpers when dealing with common interfaces like:
- [x] finalizers #291
- [ ] conditions #427
- [ ] annotations
- [ ] timestamps
- [x]
PartialObjectMetaExt- #1152 - [x] ownerrefs -
Resource::controller_owner_refcan be plumbed into aResource::owner_references_mut - [ ]
ObjectMetaExtor similar trait for stuff like https://pkg.go.dev/sigs.k8s.io/controller-runtime/pkg/controller/controllerutil ? - [x]
CustomResourceExt#497 - [ ]
CustomResourceDefinitionExt? if there are more things like this - [x]
ResourceExt#486
This issue is an umbrella issue to cross-link utils, plus a place to discuss a possible feature'd module in kube, or a kube-utils crate.
Hi @clux, reviving this old issue to inquire regarding its status, specifically about helpers for owner refs.
I've been porting a subset of controllerutils to Rust to implement functions like set_controller_reference and set_owner_reference in a project and would love to donate the code to kube-rs. Would you be interested in a PR?
Yeah, helpers like that would be very much appreciated! I think we have some logic like this already inside the finalizer helper that is utilizing jsonpatches. I personally always wanted that stuff to be a bit easier, at least for standard stuff, so implementations / sketches / ideas here here would be welcome.
Thinking this stuff would probably live in the core crate (if it's using jsonpatch), and then re-used down the line (e.g. the finalizer helper). If it's in core i am sure it would attract a bit of bikeshedding though :D
My helpers do not interact with any API by themselves. They're a straight port of controllerutil and only modify the Resource.
For instance here is the signature for set_controller_reference
fn set_controller_reference<O: Resource, K: Resource>(owner: &O, controlled: &mut K,) -> Result<(), AlreadyOwnedError>
Ah, that type of module would also probably work inside core, not what I expected, but it's probably easier than combining json patches, and it's a clever signature.
Yeah.. I think finalizers are a kind of special case, since they have "fun" timing requirements (the finalizer MUST be acknowledged by K8s BEFORE we start performing work that they'd clean up, and so on). Most should be fine to just integrate with the regular batching.