Files
operator/Cargo.toml
zeekay 468afedb43 Delete the Node of a terminated EC2 instance
k3s here runs no cloud controller, so an instance an autoscaling group
terminates leaves its Node NotReady, and a StatefulSet pod bound to it
waits for a person (five Nodes were deleted by hand on 2026-10-08).

controllers::node watches Nodes and deletes one that is not Ready, has
been not Ready for two minutes, whose providerID is
aws:///<zone>/<instance>, and whose instance EC2 reports terminated or no
longer knows. The grace keeps a Node that has just registered, or an
instance EC2 has not yet heard of, from being taken for a dead one. Any
other answer, refusal or failure deletes nothing and is asked again in a
minute. The delete carries the Node's uid. The deletion is logged.

core::ec2 is the one AWS call, DescribeInstances signed with Signature
Version 4 (hmac + sha2), tested against AWS's documented example. The
controller runs only when AWS_ACCESS_KEY_ID and AWS_SECRET_ACCESS_KEY are
set, and warns when only one is; the key pair is read through a lookup so
the gate is tested without the process environment. The operator
ClusterRole gains get/list/watch/delete on nodes.

Inert until hanzoai/universe gives the Deployment the key and the live
ClusterRole the nodes rule; LLM.md lists the three pieces.

Claude-Session: https://claude.ai/code/session_01SCPMGSQsLNF2YtHFL4bwyp
2026-10-09 04:24:50 -07:00

81 lines
2.9 KiB
TOML

[workspace]
# Standalone crate — explicit empty workspace prevents inheritance from any
# stray Cargo.toml above this directory in the parent ~/work/hanzo workspace.
[package]
name = "operator"
version = "0.7.20"
edition = "2021"
license = "BSD-3-Clause"
repository = "https://github.com/hanzoai/operator"
description = "Kubernetes operator for Hanzo platform (canonical Rust impl, all universes)"
[lib]
name = "operator"
path = "src/lib.rs"
[[bin]]
name = "operator"
path = "src/main.rs"
[[bin]]
name = "generate-crd-yaml"
path = "src/bin/generate_crd_yaml.rs"
[dependencies]
tokio = { version = "1.48", features = ["full"] }
async-trait = "0.1"
futures = "0.3"
# kube ↔ k8s-openapi ↔ schemars is a coherent set. kube 4 requires
# k8s-openapi ^0.28 and schemars ^1; the CustomResource derive emits
# schemars-1 JsonSchema, so our `#[derive(JsonSchema)]` must be schemars 1.
kube = { version = "4.0", features = ["runtime", "derive", "ws"] }
k8s-openapi = { version = "0.28", features = ["v1_33"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
serde_yaml = "0.9"
clap = { version = "4.5", features = ["derive", "env"] }
tracing = "0.1"
tracing-subscriber = { version = "0.3", features = ["env-filter"] }
thiserror = "2.0"
anyhow = "1.0"
# k8s-openapi 0.28 moved meta/v1 Time + MicroTime onto jiff::Timestamp (kube 4
# dropped chrono), so jiff is now the operator's sole timestamp library — used
# both at the k8s boundary and for the CRD-wrapper RFC3339 strings.
jiff = "0.2"
schemars = "1.0"
byteorder = "1"
base64 = "0.22"
rand = "0.9"
sha2 = "0.10"
# HMAC-SHA256 for the AWS Signature Version 4 request `core::ec2` signs.
hmac = "0.12"
# Native GitOps image automation. `semver` selects the newest matching image
# tag (range + `*`); `regex` backs the `regex:<pat>` policy. Both are already in
# the dependency tree (transitively, via kube / tracing-subscriber), so declaring
# them direct adds no new build — the ImageUpdate selection logic is pure over
# these and is the one place that reimplements a Flux GitOps-toolkit algorithm
# (semver image selection) natively rather than vendoring the toolkit.
semver = "1"
regex = "1"
# reqwest 0.13 replaced the old `rustls-tls` feature: `rustls` now pulls rustls
# core + the aws-lc-rs provider + rustls-platform-verifier (cert roots), so we
# no longer carry OpenSSL. `http2` keeps the h2 support 0.12 enabled by default.
reqwest = { version = "0.13", default-features = false, features = ["json", "http2", "rustls"] }
# rustls 0.23 compiles both aws-lc-rs (via reqwest) and ring (via kube) providers;
# install aws-lc-rs explicitly at startup (main.rs) to resolve the otherwise-ambiguous
# process-level CryptoProvider — rustls panics on first TLS use without this.
rustls = { version = "0.23", features = ["aws_lc_rs"] }
axum = "0.8"
[dev-dependencies]
tokio = { version = "1.48", features = ["full", "test-util"] }