Skip to content

Grsaiago/k8rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

K8rs: A k8s operator study in rust 🦀🦀

This operator listens for all cluster events, filters events concerning pods, logs these events, and stores metrics that are then exported to Prometheus by an http server that the controller runs concurrently on a 'green thread'. Metrics include information such as the Pod ID and the server's UTC time of the event.

Features

  • Event Monitoring: Captures all Kubernetes cluster events.
  • Pod Filtering: Focuses on pod-specific events.
  • Logging: Logs pod events using the tracing crate.
  • Metrics Exporting: Stores metrics with the metrics crate and exposes them to prometheus via a /metrics endpoint using an Axum server with axum_prometheus_exporter.

Prerequisites

  • A running Kubernetes cluster, or a local cluster created with Kind.
  • Rust and Cargo installed on your system.

Install dependencies

Clone the repository

git clone https://github.com/Grsaiago/k8rs/tree/main <where_you_want_to_clone>
cd <where_you_want_to_clone>

See it in action

Start your kind cluster

kind create cluster --config kind-cluster.yml

Build and run the operator

You can optionally build a release binary version of the operator:

cargo build --release

But this should work as well (but it'll be a debug build):

cargo run

Example

Now, whenever you run or delete a pod:

You should see the following in the Operator's console:

If you see the logs, don't forget to check out your localhost:8080/metrics to see the metrics being correctly exported to Prometheus.

About

A kubernetes operator written in Rust 🦀

Topics

Resources

Stars

Watchers

Forks

Contributors

Languages