| Crates.io | kubus |
| lib.rs | kubus |
| version | 0.6.0 |
| created_at | 2025-10-06 08:02:43.141324+00 |
| updated_at | 2026-01-20 00:22:12.067241+00 |
| description | Derive based kubernetes operator framework |
| homepage | https://github.com/juliamertz/kubus |
| repository | https://github.com/juliamertz/kubus |
| max_upload_size | |
| id | 1869911 |
| size | 102,238 |
A small Rust library for building Kubernetes operators with less boilerplate.
use std::{sync::Arc};
use k8s_openapi::api::core::v1::Pod;
use kube::{Client, ResourceExt, runtime::controller::Action};
use kubus::{Context, HandlerError, Operator, kubus};
struct State {}
#[tokio::main]
async fn main() -> Result<(), kubus::Error> {
let client = Client::try_default().await?;
let state = State {};
Operator::builder()
.with_context((client, state))
.handler(on_pod_apply)
.run()
.await
}
#[kubus(event = Apply, finalizer = "kubus.io/cleanup")]
async fn on_pod_apply(pod: Arc<Pod>, _ctx: Arc<Context<State>>) -> Result<(), HandlerError> {
let name = pod.name_unchecked();
let namespace = pod.namespace().unwrap();
println!("apply event for pod {name} in {namespace}");
Ok(())
}
The #[kubus] attribute handles the watcher setup, reconciliation loop, and finalizer management. You just write functions that handle events.
Experimental - the API will probably change as I figure out what works.