Skip to content

feat: kubernetes runner with workflow steps as native pods - #40

Open
hllvc wants to merge 50 commits into
mainfrom
feat/k8s-run-controller
Open

hllvc wants to merge 50 commits into
mainfrom
feat/k8s-run-controller

Conversation

@hllvc

@hllvc hllvc commented Oct 14, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Adds a Kubernetes runner prototype under k8s/: Private Runners as Kubernetes pods, installed with a Helm chart and scaled by a small Go controller. The run controller still runs as an ECS task through ECS Anywhere, but workflow steps run as their own Kubernetes pods. Prototype only, not supported for customer use; it needs a run controller release with step broker support, which hasn't shipped yet. Builds from this branch are published as pre-releases only (chart 0.9.0-beta.5).

Changes

  • Runner pod (k8s/runner.sh, k8s/Dockerfile): registration via main.sh, nested Docker for run controllers, SSM and ECS agents, drain and park through SG, Docker cache pruning, re-registration when the advertised size changes.
  • Step broker (k8s/scaler/internal/steps, Go): runs each step as a pod on the runner's node, mounting the run's workspace through subPath; a step wrapper turns exit codes 11/12 into Completed pods; finished pods keep an outcome label for an hour. Steps carry the run's claim, and POST /v1/runs/stop stops every step of a run by run and claim. GET /healthz lists the broker's features (claim, stop-run) so a run controller can tell what it supports. Mount sources are resolved and refused when they point outside the run's workspace.
  • Guard: a Docker authorization plugin refuses step containers in the nested daemon, so a run controller without broker support fails clearly instead of running steps there.
  • Scaler (k8s/scaler, Go): parks idle runners, wakes or adds runners on queued workflows, reaps long-parked ones; nudges node autoscalers that won't scale up for pods with persistent disks.
  • Helm chart (k8s/chart/sg-runner, Kubernetes 1.29+): size presets, broker as a native sidecar, optional NetworkPolicy, uninstall hook that deregisters every runner.
  • CI (.github/workflows/k8s.yml): Go tests, chart lint and kubeconform, multi-arch image builds, Trivy, and a kind smoke install with a broker stage.
  • Release (.github/workflows/k8s-release.yml): on a k8s/v* tag, publishes the runner and scaler images and the chart to GHCR and creates a GitHub release, marked as a pre-release when the version has a suffix such as -beta.5.
  • main.sh (affects VM runners too): private IP detection from the outbound route, and error reports no longer retry themselves when the API is down.

Testing

  • Go unit tests, bats tests, chart checks, kind smoke (including the broker and guard)
  • End to end on a managed Kubernetes cluster and a local cluster, with a run controller build that has step broker support: plan runs, approval and resume, early finish, failing step, cancel while running and while a step pod is still pending, step timeout, image pull failure, concurrent runs, broker restarts during a step, runner pod deletion (graceful and forced) during a step, log completeness (more than 5,000 numbered lines, each exactly once, also across broker restarts), guard refusing an unsupported run controller
  • CI on GitHub: all checks pass except SonarCloud Code Analysis
  • GKE/EKS: NetworkPolicy enforcement, multi-node disks, node autoscaling sized for steps

Risks

  • The main.sh changes reach VM runners: private IP detection and error-report handling. Covered by new bats tests.
  • gh release create in the release workflow does not pass --latest=false yet, so a Kubernetes release without a pre-release suffix could become the repository's latest release, which the VM install path uses. Pending change; until it lands, only pre-release tags should be pushed.
  • SonarCloud Code Analysis fails on this PR; its findings are not fixed or accepted yet.
  • Known limitation: a step can only mount paths inside the run's workspace. The step broker refuses any other mount source, so host-path mount points that work on VM runners (for example a Terraform binary or certificates mounted from the runner host) are not supported on the Kubernetes runner yet.
  • Known limitation: a step pod whose image cannot be pulled is marked failed but kept until the finished-pod TTL (one hour by default) passes, and holds its resource requests on the node until then. A broker restart starts that hour again.

Deployment Notes

  • Release ordering: the run controller change must ship before Kubernetes runners can run workflows.

hllvc added 30 commits October 12, 2026 22:10
# Conflicts:
#	k8s/Makefile
#	k8s/README.md
#	k8s/manifests/scaler.yaml
@hllvc hllvc self-assigned this Oct 14, 2026
@hllvc
hllvc force-pushed the feat/k8s-run-controller branch from a8aff03 to 2fd79c8 Compare November 26, 2026 16:25
@sonarqubecloud

Copy link
Copy Markdown

Quality Gate Failed Quality Gate failed

Failed conditions
C Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

@hllvc
hllvc marked this pull request as ready for review December 1, 2026 12:16
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