Skip to content

feat(deploy): Helm chart with the Kubernetes sandbox - #783

Closed
thecorporatetractor wants to merge 2 commits into
BaaRai:mainfrom
thecorporatetractor:feat/k8s-helm-chart
Closed

thecorporatetractor wants to merge 2 commits into
BaaRai:mainfrom
thecorporatetractor:feat/k8s-helm-chart

Conversation

@thecorporatetractor

Copy link
Copy Markdown
Contributor

Problem

The Kubernetes backend from #780 needs a deployment that wires the runner, its RBAC and the NetworkPolicies correctly. Running the panel on Kubernetes by hand also fails the isolation self-test on world-writable volumes (Bash can create files in /app/data), which is the security-context question in #620.

Change

  • New Helm chart deploy/helm/artex: panel, PostgreSQL and artex-runner with ARTEX_RUNNER_BACKEND=kubernetes, a values schema, an optional Ingress and a helm test hook.
  • The runner gets a namespace-scoped Role (pods, pods/exec, services, networkpolicies). No secrets, no cluster-wide access. Task pods use their own service account, whose token is never mounted.
  • NetworkPolicies: a chart-level default-deny covers every runner-managed pod, so a missing per-task policy fails closed. Only the panel may call the runner API and reach the database.
  • A volume-permissions init container restores root ownership of /app/data and /app/keys, so the panel's isolation self-test passes on volumes that are world-writable after provisioning (Deploying on Kubernetes Best Practises #620).
  • With a ReadWriteOnce data volume, task pods are pinned to the runner's node. ReadWriteMany lets them run on any node.
  • scripts/k3d-e2e.sh builds the images, creates a k3d cluster, installs the chart and runs TestKubeSandboxE2E (RUNNER_ONLY=1 skips the panel).
  • New kubernetes CI job: helm lint --strict and scripts/k3d-e2e.sh in runner-only mode on k3d (pinned k3d binary with a checksum). It runs only when sandbox, deploy, runner or Dockerfile paths change.
  • INSTALL.md links the chart. One CHANGELOG entry.

Depends on

Depends on #780. This branch includes its commit until #780 merges. Review only the last commit, feat(deploy): Helm chart with the Kubernetes sandbox.

Tests

Run on this branch, rebased on current main:

  • go build ./..., go vet ./..., gofmt clean, cross-builds for darwin/arm64, darwin/amd64 and windows/amd64: OK.
  • helm lint --strict deploy/helm/artex: 0 charts failed.
  • go test ./sandbox: OK. Includes 10 chart render tests (TestHelmChart*): pod security baseline, runner env, image overrides, secrets wiring, minimal RBAC, network policies, access-mode pinning, modes and options, schema rejections, lint.
  • shellcheck -S warning scripts/k3d-e2e.sh: clean.
  • Live on a new k3d cluster, images built from this branch:
    • RUNNER_ONLY=1 ARTEX_E2E_INTERNET=1 scripts/k3d-e2e.sh (the CI job): TestKubeSandboxE2E passed in 36 s, all 9 subtests (identity and hardening, workspace, exit codes/timeout/truncation, cluster objects, network isolation, in-scope egress through the proxy, kill, runner restart recovery, delete).
    • Full mode (with the panel, ARTEX_E2E_INTERNET=1): chart installed with --wait, helm test Succeeded, the panel log shows [isolation] self-test passed (the Deploying on Kubernetes Best Practises #620 failure is gone), then TestKubeSandboxE2E passed in 33 s, all 9 subtests. The cluster was deleted afterwards.

Notes

  • The runner is a single replica: it is the only writer of task pods. The chart ships no HPA for it.
  • The CI job uses the runner-only mode so it does not build the panel image.
  • Follow-ups in the next PRs: runner status API, Sandbox page and scaling (scale-to-zero, capacity cap), and scope-restricted panel egress for sandbox.mode=off.

Part of #781.

ARTEX_RUNNER_BACKEND=kubernetes runs each task in a worker pod behind its own
egress-proxy pod, created through the Kubernetes API with no container runtime
socket. Per-task NetworkPolicies are applied before the pods and removed after
them; the runner waits until they are in effect before the first command, runs
commands through pods/exec under env -i and artex-exec-wrap, and re-adopts task
pods after a restart. Unit tests run against a fake API server; a live test
(TestKubeSandboxE2E) drives a deployed runner.
@thecorporatetractor

Copy link
Copy Markdown
Contributor Author

Rebased onto main after #775 merged. The only conflict was in CHANGELOG (CRLF kept). All checks pass on 8f5d800, including the new kubernetes job: helm lint --strict plus the k3d e2e suite on the GitHub runner (run).

deploy/helm/artex deploys the panel, PostgreSQL and artex-runner with a
namespace-scoped Role, default-deny NetworkPolicies and a values schema. A
volume-permissions init container restores root ownership of /app/data and
/app/keys, fixing the isolation self-test failure on world-writable volumes
(BaaRai#620). scripts/k3d-e2e.sh and the kubernetes CI job test it live on k3d.
@BaaRai

BaaRai commented Dec 2, 2026

Copy link
Copy Markdown
Owner

Thanks for the work. This PR is 4,693 lines across 21 files, above the review threshold we can apply line by line (2,500 lines or 15 files). I am parking it for the current wave rather than closing it: the PR stays open and the work is kept.

To get it reviewed, please split it by subsystem into PRs under that threshold. For this one, a natural split is: Helm chart, values and docs, tests.

If the feature is already on the roadmap, link the tracking issue and we will pick it up there.

@BaaRai BaaRai added the feature label Dec 2, 2026
@thecorporatetractor

Copy link
Copy Markdown
Contributor Author

Closing in favour of the smaller PRs listed in #781, which land one at a time. The branch stays on the fork as the reference for the full feature.

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

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants