roperator

Experimental Kubernetes Operator kit written in Rust

Documentation:

This project is maintained by psFried

Setting up a new Rust project

You’ll first need to make sure you have just a couple of pre-requisites installed

Create a new Rust project

Now you’re ready to create a new Rust project. Run cargo new --bin example-operator, replacing example-operator with whatever name you want.

~/projects$ cargo new --bin example-operator
     Created binary (application) `example-operator` package

This should create the following files:

example-operator/
├── Cargo.toml
└── src
    └── main.rs

1 directory, 2 files

Change directory into your project and run cargo run to ensure that everything works correctly. You should see something like the following:

~/projects/example-operator$ cargo run
   Compiling example-operator v0.1.0 (/Users/pfried/projects/example-operator)
    Finished dev [unoptimized + debuginfo] target(s) in 1.54s
     Running `target/debug/example-operator`
Hello, world!

Add the Roperator dependency

Edit Cargo.toml and add the following:

[dependencies]
roperator = "*"

# There's lots of "right" ways to setup logging, so feel free to use something else. For this example, we'll use the `env_logger` crate
log = "0.4"
env_logger = "0.7"

# This is only needed if you intend to use the builtin testkit for testing your operator, which is probably a good idea
[dev-dependencies]
roperator = { version = "*", features = ["testkit"] }

Next

Configure the parent Custom Resource Definition