You can check the operator yourself here, or use it as boilerplate code to start your own rust operator.
A little bit of background
I’ve been writing Kubernetes operators for quite some time now, and while I appreciate the tools that is provided by kubebuilder, it is becoming quite an undertaking to build and operator these days. Since I love rust I wondered if the tools were mature enough to write an operator in Rust and is it better than go and kubebuilder.
The Comparison
With a little research, I quickly found that kube-rs is actually providing most of the tools that you need to build a production ready operator so I decide to write a quick one to get a feel of how the rust version works. To my surprise I found it is quite a pleasant experience, and for me it is actually better than kubebuilder and go.
The really good
- The rust code was mostly straight forward you can easily follow the code from start to finish and figure out where to need to improve stuff for the sake of performance or functionality
- Less code annotations is something that is always welcome, while there was heavy macro usage like in the type definitions, but I always find that macros are better to read.
- The rust code has significantly less boilerplate which make it easy to maintain on the long run as you can introduce more engineers to the code easily.
- Something that you get automatically when you use rust is memory safety, and the really better performance and less resource usage, which makes it more suitable to high performance operators.
- The use of Async and tokio.rs in the design of the operator makes kube-rs really scalable and reduces the complexity to implement non-blocking network calls which expands the possibility of what can be done in the operator.
The slightly less good
- The compile time of least viable rust operator, is really long compared to Golang and kubebuilder.
- The community is still small, so you will need to know your way around Kubernetes APIs and rust before using kube-rs.
A small conclusion
In the end I really, enjoy writing rust and the possibility of using it in my main job while also being more productive is a dream come true for me.
Leave a comment