Skip to content

bartvanbenthem/operator-sdk-rs

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

72 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Kubernetes Operator SDK for Rust

The project behind koprs, a high-level Kubernetes operator library for Rust.

Operators make it easy to manage complex stateful applications on top of Kubernetes. However writing an Operator today can be difficult because of challenges such as using low level APIs, writing boilerplate, and a lack of modularity which leads to duplication.

The Operator SDK for Rust is a framework that uses kube and kube-runtime libraries to make writing operators easier by providing:

  • High level APIs and abstractions to write the operational logic more intuitively
  • Tools for scaffolding and code generation to bootstrap a new project fast
  • Extensions to cover common Operator use cases

This repository contains the core framework, its proc macros, and the manifest generation tooling for CRDs and RBAC.

Crates

Crate Description Docs
koprs Core generic runtime framework docs.rs crates.io
koprs-derive Proc macros — implementation detail docs.rs crates.io
koprs-gen CRD and RBAC manifest generation CLI docs.rs crates.io

Workspace layout

operator-framework-rs/
├── Cargo.toml                  # workspace manifest
├── Cargo.lock
└── crates/
    ├── koprs/                  # core library
    ├── koprs-derive/           # proc macros
    └── koprs-gen/              # codegen CLI

Getting started

If you are here to build a Kubernetes operator, you want koprs. Start there.

If you want to generate CRD or RBAC manifests from your annotated Rust types, you want koprs-gen.

Contributing

Contributions are welcome. Please open an issue before submitting a pull request for anything beyond small fixes, so the approach can be agreed on first.

Prerequisites

  • Rust stable toolchain
  • A local Kubernetes cluster for integration tests (kind recommended)

Build

# build all crates
cargo build

# build a specific crate
cargo build -p koprs

Test

# unit tests (no cluster required)
cargo test

# integration tests
kind create cluster --name operator-framework-rs-test
cargo test --features integration --test integration
kind delete cluster --name operator-framework-rs-test

CI

cargo-ci.sh runs all quality checks in sequence — format, type-check, unit tests, integration tests, coverage, release build, docs, and audit.

./scripts/cargo-ci.sh                           # run all steps
./scripts/cargo-ci.sh --fast                    # fmt + check + unit tests only (no coverage)
./scripts/cargo-ci.sh --no-audit                # skip cargo-audit
./scripts/cargo-ci.sh --no-integration          # skip integration tests
./scripts/cargo-ci.sh --no-doc                  # skip cargo doc
./scripts/cargo-ci.sh --no-coverage             # skip llvm-cov coverage report
./scripts/cargo-ci.sh --bench                   # also compile benchmarks (slow, opt-in)
./scripts/cargo-ci.sh --coverage-fail-under=80  # fail if line coverage drops below N%

Publishing

publish.sh handles the full pre-flight and publishes all three crates to crates.io in dependency order — koprs-derive, koprs, koprs-gen.

./scripts/publish.sh                    # full pre-flight + publish all crates
./scripts/publish.sh --dry-run          # stop before cargo publish
./scripts/publish.sh --skip-ci          # skip CI checks, publish only
./scripts/publish.sh --crate koprs      # publish a single crate

A 20 second delay is applied between each crate to allow crates.io to index before the next crate resolves it as a registry dependency.

See the CI script docs for the full list of flags.

License

MIT

About

SDK for building Kubernetes applications in Rust. Provides high level APIs, useful abstractions, and project scaffolding.

Topics

Resources

Stars

Watchers

Forks

Packages

 
 
 

Contributors