explaingit

kube-rs/kube

Analysis updated 2026-07-03

3,704RustAudience · ops devopsComplexity · 4/5Setup · hard

TLDR

A Rust library for working with Kubernetes clusters: list, create, and delete resources, stream change events, cache cluster state, and build automated controllers.

Mindmap

mindmap
  root((kube-rs))
    API layer
      Get and list resources
      Create and update
      Custom resource types
      Derive macro
    Runtime layer
      Watcher streams
      Reflector cache
      Change events
    Controller layer
      Reconcile function
      Retry and scheduling
      Child resource watching
    Infrastructure
      Kubernetes v1.31 plus
      CNCF Sandbox project
      kube.rs docs
Click or tap to explore — scroll the page freely

Code map

Detail Auto

An interactive map of this repo's files and how they connect — its source is parsed live in your browser. Click Visualize to build it.

filefunction / class

What do people build with it?

USE CASE 1

List, create, update, or delete any Kubernetes resource from a Rust program using a single generic API.

USE CASE 2

Build a Kubernetes operator in Rust that watches custom resources and runs a reconcile function when they change.

USE CASE 3

Maintain an in-memory cache of cluster state with a reflector so your code can query resources without live API calls.

USE CASE 4

Stream continuous change events from the cluster with automatic reconnection and pagination handled for you.

What is it built with?

RustKubernetesTokioasync/await

How does it compare?

kube-rs/kubevlcn-io/cr-sqlitecurlpipe/ox
Stars3,7043,7033,702
LanguageRustRustRust
Setup difficultyhardmoderateeasy
Complexity4/53/52/5
Audienceops devopsdeveloperdeveloper

Figures from each repo's GitHub metadata at analysis time.

How do you get it running?

Difficulty · hard Time to first run · 1h+

Requires a running Kubernetes cluster (local via kind or minikube, or remote) with a valid kubeconfig file.

In plain English

kube-rs is a Rust library for interacting with Kubernetes. Kubernetes is a system for running and managing containerized applications across a cluster of machines. This library gives Rust programs a way to talk to a Kubernetes cluster: listing pods and other resources, modifying them, watching for changes, and building automated controllers that respond when things change. The library has three main layers. The first is the API layer, which covers the basics: get, create, update, patch, and delete any Kubernetes resource. It is generic, meaning you use the same interface whether you are working with built-in resource types like pods and services, or with custom resource definitions you define yourself. A derive macro generates the Kubernetes-specific boilerplate for custom types automatically from a Rust struct, similar to how kubebuilder works in Go. The second layer is the runtime, which adds higher-level abstractions. A watcher gives you a continuous stream of change events from the cluster without you needing to manage connection restarts or pagination yourself. A reflector is a watcher that also maintains a local in-memory cache of current state, so you can query what resources exist at any point without making a fresh API request. The third layer is the controller runtime. It builds on watchers and reflectors to help you write Kubernetes operators: programs that monitor resources and take action when they change. You provide a reconcile function and an error policy, and the controller handles scheduling, retry logic, and watching both primary and related child resources. kube-rs is hosted by the Cloud Native Computing Foundation (CNCF) as a Sandbox project and supports Kubernetes v1.31 and above. Full documentation is available at kube.rs.

Copy-paste prompts

Prompt 1
Using kube-rs, write a Rust function that lists all pods in the default namespace and prints their names and current status.
Prompt 2
Show me how to define a custom Kubernetes resource in Rust using the kube derive macro and then list instances of it from the cluster.
Prompt 3
How do I write a Kubernetes controller with kube-rs that watches a CRD and reconciles state whenever an instance is created or updated?
Prompt 4
Set up a kube-rs reflector to cache all Deployments in a namespace and query them without making live Kubernetes API requests.
Prompt 5
How do I configure error handling and retry backoff in a kube-rs controller runtime reconcile loop?

Frequently asked questions

What is kube?

A Rust library for working with Kubernetes clusters: list, create, and delete resources, stream change events, cache cluster state, and build automated controllers.

What language is kube written in?

Mainly Rust. The stack also includes Rust, Kubernetes, Tokio.

How hard is kube to set up?

Setup difficulty is rated hard, with roughly 1h+ to a first successful run.

Who is kube for?

Mainly ops devops.

Open on GitHub → Explain another repo

This repo across BitVibe Labs

Scan in gitsafehub Deploy in gitdeployhub kube-rs on gitmyhub

Verify against the repo before relying on details.