NAME := "controller"
ORG := "localhost:5001"
VERSION := `git rev-parse HEAD`
SEMVER_VERSION := `grep version Cargo.toml | awk -F"\"" '{print $2}' | head -n 1`
NAMESPACE := "default"
KUBE_VERSION := "1.25"
default:
@just --list --unsorted --color=always | rg -v " default"
# generate crd
generate-crd:
cargo run --bin crdgen > charts/coredb-operator/templates/crd.yaml
# generate and install crd into the cluster
install-crd: generate-crd
kubectl apply -f charts/coredb-operator/templates/crd.yaml
# delete kind
delete-kind:
kind delete cluster && sleep 5
# start kind
start-kind:
kind create cluster --config testdata/kind-{{KUBE_VERSION}}.yaml
sleep 10
kubectl wait pods --for=condition=Ready --timeout=300s --all --all-namespaces
just install-crd
just annotate
# run with opentelemetry
run-telemetry:
OPENTELEMETRY_ENDPOINT_URL=https://0.0.0.0:55680 RUST_LOG=info,kube=debug,controller=debug cargo run --features=telemetry
# run without opentelemetry
run:
RUST_LOG=debug,kube=debug,controller=debug cargo run
# annotate namespace to allow for tests
annotate:
kubectl label namespace {{NAMESPACE}} safe-to-run-coredb-tests=true
# run tests
test:
cargo test -- --ignored --nocapture
# run cargo watch
watch:
ENABLE_INITIAL_BACKUP=false RUST_LOG=debug cargo watch -x 'run'
# format with nightly rustfmt
fmt:
cargo +nightly fmt
# compile for musl (for docker image)
compile features="":
#!/usr/bin/env bash
docker run --rm \
-v cargo-cache:/root/.cargo \
-v $PWD:/volume \
-w /volume \
-t clux/muslrust:stable \
cargo build --release --features={{features}} --bin controller
cp target/x86_64-unknown-linux-musl/release/controller .
# docker build (requires compile step first)
build:
docker build -t {{ORG}}/{{NAME}}:{{VERSION}} .
# retag the current git versioned docker tag as latest, and publish both
tag-latest:
docker tag {{ORG}}/{{NAME}}:{{VERSION}} {{ORG}}/{{NAME}}:latest
docker push {{ORG}}/{{NAME}}:{{VERSION}}
docker push {{ORG}}/{{NAME}}:latest
# retag the current git versioned docker tag as the current semver and publish
tag-semver:
#!/usr/bin/env bash
if curl -sSL https://registry.hub.docker.com/v1/ORGsitories/{{ORG}}/{{NAME}}/tags | jq -r ".[].name" | grep -q {{SEMVER_VERSION}}; then
echo "Tag {{SEMVER_VERSION}} already exists - not publishing"
else
docker tag {{ORG}}/{{NAME}}:{{VERSION}} {{ORG}}/{{NAME}}:{{SEMVER_VERSION}} .
docker push {{ORG}}/{{NAME}}:{{SEMVER_VERSION}}
fi
# local helpers for debugging traces
# forward grpc otel port from svc/promstack-tempo in monitoring
forward-tempo:
kubectl port-forward -n monitoring svc/promstack-tempo 55680:55680
# forward http port from svc/promstack-grafana in monitoring
forward-grafana:
kubectl port-forward -n monitoring svc/promstack-grafana 8000:80
# mode: makefile
# End:
# vim: set ft=make :