You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
A lot of code to interact with Kubernetes API was implemented as part of #2653. We'd like to extract this code into a shared crate of some kind.
Motivation
We want to contribute to the community and let other projects use this work.
We'd like to get rid of the burden of maintaining all this code as part of the Vector code base.
We'd like part of the community that's better involved with k8s to do an audit and review of this code.
Context
There were a few reasons why we implemented the code ourselves in the first place, and didn't use some existing crate:
Actually, we are using k8s-openapi - it provides some machine-generated rust types and serialization/deserialization based on the OpenAPI spec for the Kubernetes API.
As part of the plan at chore: Kubernetes Integration RFC #2222, we wanted to build upon the existing code.
The new code is very heavily inspired by the WatchClient (it too doesn't rely on anything higher level than k8s-openapi, and uses evmap). WatchClient had very good design decisions, and I attempted to use higher-level crates, but quickly got back to the same core design for various reasons - more on this later.
Existing crates at the time were (and still are) very limiting. One of the requirements to the client crate was the ability to use our http clients facilities. None of the crates had this flexibility.
Additional layers of crates were an unwanted growth in complexity and a lack of flexibility.
Halfway through the implementation, it became evident that this factor is very important, as I had to debug and fix issues at the bottom of the library stack. It would've been way more difficult to do if there were additional layers.
It wasn't clear what architecture to use upfront, and I had to try and swap a few before I ended up with what we got. Using external crates limited the design space significantly, and not in our favor.
The most promising crate kube - the only one actively maintained. It's problematics though - lot of things are hard-coded to a particular implementation, rather than being generic around a trait. It also provides a lot of very basic custom functionality that's manually implemented, rather than being based on k8s-openapi (which it also depends on). The test coverage is also lacking. All those factors repelled me from relying on that crate so far.
The implementation we ended up with is well tested, modular and usable on it's own, with the only dependency being k8s-openapi. Technically, we can just extract into it's own crate, and invite users to depend on directly. We can implement adapters for compatibility with kube crate too.
Another option is we can work with people maintaining kube crate to improve the modularity of their crate, probably port our code there, and then we could switch to using kube crate. Although it's a lot more work than just extracting the code to a new crate, we'll get the community more involved in the process, and, eventually, transition the maintenance to the community completely.
We probably can start with extracting the crate (7), and then talking about sending patches to kube crate (8) - that way we'll start having the benefits of a cleaner code separation earlier - and there'd earlier be fewer things to think about for the Vector team.
Plan
Extract the implementation into a subcrate at lib/.
Alter the API, prepare for adoption into kube. Discuss things with them.
Prepare patches to kube.
Merge and support kube code changes.
Update our implementation with the upstreamed kube variant.
I'm very looking forward to sharing what I implemented for Vector with the community because there's nothing quite like it available out there yet.
A lot of code to interact with Kubernetes API was implemented as part of #2653. We'd like to extract this code into a shared crate of some kind.
Motivation
Context
There were a few reasons why we implemented the code ourselves in the first place, and didn't use some existing crate:
k8s-openapi- it provides some machine-generated rust types and serialization/deserialization based on the OpenAPI spec for the Kubernetes API.The new code is very heavily inspired by the
WatchClient(it too doesn't rely on anything higher level thank8s-openapi, and usesevmap).WatchClienthad very good design decisions, and I attempted to use higher-level crates, but quickly got back to the same core design for various reasons - more on this later.httpclients facilities. None of the crates had this flexibility.Halfway through the implementation, it became evident that this factor is very important, as I had to debug and fix issues at the bottom of the library stack. It would've been way more difficult to do if there were additional layers.
kube- the only one actively maintained. It's problematics though - lot of things are hard-coded to a particular implementation, rather than being generic around a trait. It also provides a lot of very basic custom functionality that's manually implemented, rather than being based onk8s-openapi(which it also depends on). The test coverage is also lacking. All those factors repelled me from relying on that crate so far.k8s-openapi. Technically, we can just extract into it's own crate, and invite users to depend on directly. We can implement adapters for compatibility withkubecrate too.kubecrate to improve the modularity of their crate, probably port our code there, and then we could switch to usingkubecrate. Although it's a lot more work than just extracting the code to a new crate, we'll get the community more involved in the process, and, eventually, transition the maintenance to the community completely.kubecrate (8) - that way we'll start having the benefits of a cleaner code separation earlier - and there'd earlier be fewer things to think about for the Vector team.Plan
lib/.kube. Discuss things with them.kube.kubecode changes.kubevariant.I'm very looking forward to sharing what I implemented for Vector with the community because there's nothing quite like it available out there yet.