pkozelka / rust-kubernetes-operator-example

An example of a Kubernetes operator implemented in Rust

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Rust Kubernetes operator example

A Kubernetes operator built on top of kube-rs project. There is an explanatory article available.

Steps to run on Linux:

  1. Install Rust
  2. Install Kubernetes, K3S.io is an excellent choice, installed simply with curl -sfL https://get.k3s.io | sh -. Make sure to sudo chown /etc/rancher/k3s/k3s.yaml $USER if you're accessing the Kubernetes cluster using the kubeconfig at /etc/rancher/k3s/k3s.yaml as non-root user. Also, export KUBECONFIG=/etc/rancher/k3s/k3s.yaml, so the operator can find the kubeconfig.
  3. Use kubectl apply -f echoes.example.com.yaml to create the CustomResourceDefinition inside Kubernetes.
  4. Run the operator using cargo run. It will run outside of the Kubernetes cluster and connect to the Kubernetes REST API using the account inside the KUBECONFIG automatically.

Finally, a custom Echo resource can be created with kubectl apply -f echo-example.yaml. A new deployment of two pods with Echo REST API service will be created. This can be checked with the kubectl get pods or kubectl get deployments command.

Usage showcase

About

An example of a Kubernetes operator implemented in Rust


Languages

Language:Rust 100.0%