Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Latest commit

 

History

History
130 lines (88 loc) · 3.15 KB

developers.md

File metadata and controls

130 lines (88 loc) · 3.15 KB

Developer guide

This guide explains how to set up your environment for developing Krator.

Prerequisites

To build Krator, you will need

  • The latest stable version of Rust
  • openssl (Or use the rustls-tls feature)
  • git

If you want to test Krator, you will also require

Building

We use cargo to build our programs:

$ cargo build

Krator is a library crate, meaning that you cannot run Krator directly, but must import it into other "binary" crates which can then be run. To see an example of using Krator in this way, check out the moose example.

Krator does not configure k8s-openapi to use a specific version of Kubernetes. You will need to select a version and enable its feature when building your application:

[dependencies.k8s-openapi]
version = "0.13"
default-features = false
features = ["v1_22"]

Krator is tested against Kubernetes v1.22.

Building without openssl

If you are on a system that doesn't have OpenSSL (or has the incorrect version), you have the option to build Krator using the Rustls project (Rust native TLS implementation):

$ cargo build --no-default-features --features rustls-tls

The same flags can be passed to cargo run if you want to just run the project instead.

Caveats

The underlying dependencies for Rustls do not support certs with IP SANs (subject alternate names). Because of this, the serving certs requested during bootstrap will not work for local development options like minikube or KinD as they do not have an FQDN

Building on WSL (Windows Subsystem for Linux)

You can build Krator on WSL but will need a few prerequisites that aren't included in the Ubuntu distro in the Microsoft Store:

$ sudo apt install build-essential libssl-dev pkg-config

NOTE: We've had mixed success developing Krator on WSL. It has been successfully run on WSL2 using the WSL2-enabled Docker Kubernetes or Azure Kubernetes. If you're on WSL1 you may be better off running in a full Linux VM under Hyper-V.

Building on Windows

We have support for building on Windows using PowerShell:

$ cargo build --no-default-features --features rustls-tls

NOTE: Windows builds use the rustls library, which means there are some things to be aware of. See the caveats section for more details

Running

The included example with Krator is the moose example.

cargo run --example moose

Testing

Krator contains both unit tests and doc tests, and is routinely checked using clippy and rustfmt as well.

For unit tests:

$ cargo test --workspace

For doc tests:

$ cargo test --doc --all

For clippy:

$ cargo clippy --workspace

For rustfmt:

cargo fmt --all -- --check

Creating your own Operators with Krator

If you want to create your own Operator based on Krator, all you need to do is implement an Operator. See the moose example to see how this is done.