Skip to content

Development Setup

Set up your local environment for 5-Spot development.

Prerequisites

Required

  • Rust: 1.75 or later (install via rustup)
  • kubectl: Configured with cluster access
  • Docker: For container builds

Optional

  • kind: For local Kubernetes clusters
  • minikube: Alternative local cluster
  • cargo-watch: For development hot-reload

Installation

Clone the Repository

git clone https://github.com/finos/5-spot.git
cd 5-spot

Install Rust Dependencies

# Install Rust if not already installed
curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh

# Ensure you have the latest stable Rust
rustup update stable

Install Development Tools

# Code formatting
rustup component add rustfmt

# Linting
rustup component add clippy

# Watch mode (optional)
cargo install cargo-watch

Building

Debug Build

cargo build

Release Build

cargo build --release

Generate CRDs

cargo run --bin crdgen > deploy/crds/scheduledmachine.yaml

Generate API Documentation

cargo run --bin crddoc > docs/reference/api.md

Running Locally

Prerequisites

  1. A Kubernetes cluster (kind, minikube, or remote)
  2. CAPI installed on the cluster
  3. kubectl configured to access the cluster

Install CRDs

kubectl apply -f deploy/crds/scheduledmachine.yaml

Run the Operator

# Development mode with debug logging
RUST_LOG=debug cargo run

# Or with cargo-watch for auto-reload
cargo watch -x run

Testing

Run All Tests

cargo test

Run Specific Tests

# Run tests matching a pattern
cargo test schedule

# Run tests in a specific module
cargo test --lib crd_tests

Run with Output

cargo test -- --nocapture

Code Quality

Format Code

cargo fmt

Lint Code

cargo clippy -- -D warnings

Check All

# Format, lint, and test
cargo fmt && cargo clippy -- -D warnings && cargo test

IDE Setup

VS Code

Recommended extensions: - rust-analyzer - Even Better TOML - crates

Settings (.vscode/settings.json):

{
  "rust-analyzer.checkOnSave.command": "clippy",
  "editor.formatOnSave": true
}

IntelliJ IDEA / RustRover

  • Install Rust plugin
  • Enable rustfmt on save
  • Configure clippy as external linter

Local Kubernetes

kind

# Create cluster
kind create cluster --name 5spot-dev

# Install CAPI
clusterctl init

# Apply CRDs
kubectl apply -f deploy/crds/

minikube

# Start cluster
minikube start --cpus 4 --memory 8g

# Install CAPI
clusterctl init

# Apply CRDs
kubectl apply -f deploy/crds/