Hello, Kubernetes đŸ¦€

Hello, Kubernetes đŸ¦€

A Hello World equivalent of Kubernetes and Rust

·

2 min read

The Kubernetes ecosystem is mostly written in Golang, but occasionally, rust has entered the ecosystem. Linkerd re-implementation, Youki Container Runtime, OpenEBS and TiKV are noticeable mentions. You can read more about this at

Around one and a half years after this article, kube.rs was accepted to CNCF incubation on November 16, 2021. This opened doors to possibilities for writing tools and controllers for Kubernetes. Since then the community has demonstrated from time to time how to write tools and controllers using Rust for the Kubernetes ecosystem.

Let’s get started with our Hello Kubernetes example. To keep things simple, in this example, I have used a kind cluster on my and the client is connecting to the default kubeconfig location ~/.kube/config. We are using Tokio for async runtime. we will be listing pods from the kube-system namespace.

  • Step 1 Create the project

Assuming that you have some familiarity with rust and it is installed on your local machine. Let’s create a new directory and initialize the Rust project.

  • Step 2 Ensuring Dependencies

Add kube-rs, k8s-openapi, and tokio dependencies to the Cargo.toml file

  • Step 3 Writing main code

  • Step 4 Build

    Trigger build using cargo build —release

  • Step 5 Run


In the next article, we will be building a toy implementation of kubectl binary, with get list and watch functionality.

Â