A toy tool for generating Kubernetes manifests in Rust
My personal criticism of Helm is the part where it generates Kubernetes resources by composing YAML with text templates. Actually, the template/values pattern of Helm charts is also used in kube-prometheus’s jsonnet, and there’s a need to abstract and manage complex configurations.
I particularly think that Kubernetes resources are not suitable for text templating like HTML. These manifest files represent various APIs supported by Kubernetes and are essentially structured data. And I thought that the most effective tool for processing structured data is a programming language.
Given that Kubernetes is essentially an API, and all operations performed within a Kubernetes cluster (such as creating Pods or monitoring services) ultimately involve interaction with that API. The Kubernetes API server automatically generates and provides complete OpenAPI specifications for all resources and operations.
So with the help of (recently trendy) vibe coding, I wrote kamut in Rust.
The basic structure is simple. By writing deploy.kamut.yaml
as follows, you can generate deploy.yaml
with the kamut
CLI.
deploy.kamut.yaml
deploy.yaml
Because it uses definitions for structured data (structs generated based on OpenAPI spec), validation of structural flaws is possible during manifest generation. Actually, generation becomes impossible if there are structural issues.
In Rust, there are also libraries for definitions of resource types in the Kubernetes client API that are automatically generated from the Kubernetes OpenAPI specification.
- metio/kube-custom-resources-rs: Kubernetes Custom Resource Bindings for Rust
- Arnavion/k8s-openapi: Rust definitions of the resource types in the Kubernetes client API
Since Kamut is a toy project for learning Rust, if you’re interested in this approach and want to try it out, I’d recommend yoke. ;-)