Skip to content

feat(stack): pluggable backend system with native k3s support#135

Open
bussyjd wants to merge 1 commit intointegration-okr-1from
feature/k3s-backend
Open

feat(stack): pluggable backend system with native k3s support#135
bussyjd wants to merge 1 commit intointegration-okr-1from
feature/k3s-backend

Conversation

@bussyjd
Copy link
Collaborator

@bussyjd bussyjd commented Feb 6, 2026

Summary

  • Introduces a Backend interface that abstracts cluster lifecycle, enabling both k3d (default) and native k3s backends
  • Native k3s is a prerequisite for TEE/Confidential Computing — k3d cannot provide the direct hardware access needed for AMD SEV-SNP, Intel TDX, or GPU TEE workloads
  • Fixes pre-existing helmfile template issues (eRPC secretEnv type mismatch, obol-frontend escaped quotes, .Values.* unavailable during gotmpl first-pass rendering)

What changed

Area Change
Backend interface New Backend with Init, Up, Down, Destroy, IsRunning, DataDir — k3d extracted into K3dBackend, new K3sBackend added
k3s process management PID tracking, sudo kill -0 liveness checks, process group signals, k3s-killall.sh cleanup, API server readiness polling
Helmfile templates helmfile.yamlhelmfile.yaml.gotmpl, env vars replace .Values.* references, KUBECONFIG propagated to hooks
eRPC values secretEnv changed from nested map to {}, secret injected via extraEnv with valueFrom.secretKeyRef
obol-frontend values Replaced {{ printf \"...\" }} with direct interpolation and single-quoted env calls
Tests 26 unit tests (backend selection, PID parsing, config, Init templates) + 10 integration test scenarios behind //go:build integration

Test results

  • Unit tests: 26/26 pass with -race
  • K3s integration: 32/33 flow tests pass (11 scenarios: init, up, kubectl, idempotent, down, restart, purge)
  • Helmfile deploy: All 10 releases succeed on k3s (base, reloader, monitoring, gateway-api-crds, traefik, cloudflared, erpc, erpc-httproute, obol-frontend, obol-frontend-httproute)

Test plan

  • Unit tests pass (go test -race ./internal/stack/)
  • K3s: stack init --backend k3sstack up → full helmfile deploy
  • K3s: stack downstack up restart cycle
  • K3s: stack purge --force full cleanup
  • K3d: backward compatibility (blocked by local Docker/kernel issue, not code-related)
  • Network install on k3s backend

Closes #134

Introduce a Backend interface that abstracts cluster lifecycle management,
enabling both k3d (Docker-based, default) and k3s (native bare-metal) backends.
This is a prerequisite for TEE/Confidential Computing workloads which require
direct hardware access that k3d cannot provide.

Changes:
- Add Backend interface (Init, Up, Down, Destroy, IsRunning, DataDir)
- Extract k3d logic into K3dBackend with backward-compatible fallback
- Add K3sBackend with sudo process management, PID tracking, and
  API server readiness checks
- Convert helmfile.yaml to helmfile.yaml.gotmpl using env vars instead
  of .Values references (fixes first-pass template rendering)
- Fix eRPC secretEnv type mismatch (map vs string for b64enc)
- Fix obol-frontend escaped quotes in gotmpl expressions
- Add KUBECONFIG env var to helmfile command for hook compatibility
- Add 26 unit tests and 10 integration test scenarios

Closes #134
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant