🤖 feat: add kind dev cluster scaffolding and k9s tooling#27
Conversation
|
@codex review Please review this PR for correctness and readiness. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 68c079f361
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
|
@codex review Addressed feedback: exported kubeconfig/context before first kubectl call in |
|
Codex Review: Didn't find any major issues. Bravo. ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
This PR adds a repeatable KIND-based local dev/demo workflow for the controller and k9s-driven cluster inspection.
Background
The repo already uses KIND for CI smoke tests, but local setup previously required manual steps and separate tool installation. This change makes the workflow repo-native and easier to run in Coder workspaces.
Implementation
kubectl,kind,k9s) to the Nix devshell.hack/kind-dev.shwith commands for:up,ctx,load-image,k9s,status,downkind-devscript commands..mux/skills/kind-dev/SKILL.mdfor per-workspace agent usage.Validation
bash -n hack/kind-dev.shmake -n kind-dev-up kind-dev-ctx kind-dev-load-image kind-dev-status kind-dev-k9s kind-dev-downmake buildmake lintmake testmake verify-vendorRisks
Low risk. Changes are additive and primarily developer tooling/documentation. Potential impact is limited to local dev ergonomics and optional scripts.
📋 Implementation Plan
Add k9s to Nix devshell + KIND dev-cluster scaffolding
Context / Why
You’re developing
coder-k8sfrom a Coder workspace and want a “real” Kubernetes cluster so you can demo the operator with tools like k9s (instead of onlyenvtest). The repo already has a minimal KIND-based smoke test in CI; the goal is to make that workflow easy and repeatable locally by:k9sto the Nix devshell, andhack/) that spin up a KIND cluster and install prerequisites (CRDs/RBAC + optional namespace/SA) so you can start the controller yourself and then demo it with k9s.Evidence (repo reality)
flake.nixdevshell currently includes Go/tooling but does not includek9s..github/workflows/ci.yamlhas ane2e-kindjob that:coder-k8sin the repo root (go build -o coder-k8s ./withGOOS=linux,GOARCH=amd64,CGO_ENABLED=0)Dockerfile.goreleaserconfig/crd/bases/,config/rbac/, andconfig/e2e/, then applies the sample CR.Dockerfile.goreleaserexpects the binary at the repo root:COPY coder-k8s /coder-k8s.config/e2e/deployment.yamldeploys the controller into namespacecoder-systemas deploymentcoder-k8swith imageghcr.io/coder/coder-k8s:e2eandimagePullPolicy: Never(sokind loadis required).Makefile’sbuildtarget runsgo build ./...and does not produce the./coder-k8sbinary needed byDockerfile.goreleaser.hack/currently contains standalone bash scripts (update-*.sh) and is the best-fit location for “dev loop” helpers.Note on what the controller does today
internal/controller/codercontrolplane_controller.gois currently a no-op skeleton: it fetches the CR and logs at verbosity V(1), but does not create any dependent objects or update Status. The dev-cluster scaffolding below will still be useful (you can demo CRD install + controller reconcile triggers/logs), but a future small enhancement could setstatus.phaseor emit an Event to make k9s demos more visually interesting.Implementation plan
1) Add
k9s,kubectl, andkindto the Nix devshellFile:
flake.nixAdd
k9s,kubectl, andkindto thepackageslist of thedefaultdevShell.This makes
nix developsufficient for spinning up a KIND cluster and running k9s demos without ad-hoc installs.2) Add a KIND dev-cluster setup script:
hack/kind-dev.shFile:
hack/kind-dev.sh(new, executable)Create one entrypoint script with subcommands to avoid duplicating bash boilerplate across multiple files.
Goals
coder-systemnamespace/ServiceAccount), but do not start the controller for you.up).k9s.Interface
./hack/kind-dev.sh up— create cluster (if needed) + install CRDs/RBAC + createcoder-systemnamespace/ServiceAccount/Binding (does not deploy the controller) + set current kubectl context to the cluster./hack/kind-dev.sh ctx— set current kubectl context to the cluster (short for “context”; useful if you overrodeCLUSTER_NAMEor switched away)./hack/kind-dev.sh load-image— build a Linux./coder-k8sbinary, build the container image, andkind loadit (pre-req for in-cluster deployment)./hack/kind-dev.sh k9s— open k9s on the cluster context./hack/kind-dev.sh status— print usefulkubectlstatus output./hack/kind-dev.sh down— delete the clusterDefaults / config knobs (env vars)
CLUSTER_NAMEdefault:coder-k8s-dev(ifMUX_WORKSPACE_NAMEis set, default tocoder-k8s-${MUX_WORKSPACE_NAME}to avoid collisions); override viaCLUSTER_NAME=...KUBE_CONTEXTderived:kind-${CLUSTER_NAME}NAMESPACEdefault:coder-systemDEPLOYMENTdefault:coder-k8sIMAGEdefault:ghcr.io/coder/coder-k8s:e2e(must matchconfig/e2e/deployment.yamlunless you also patch manifests)GOARCHdefault:$(go env GOARCH)(withGOOS=linux,CGO_ENABLED=0)Script shape (sketch)
Notes:
#!/usr/bin/env bash,set -euo pipefail, repo-root resolution, and “assertion failed:” wording for missing prerequisites.go build -o coder-k8s ./(CI-compatible) rather thanmake build, because the Dockerfile requires the root binary.3) (Recommended) Add Makefile wrappers for discoverability
File:
MakefileAdd phony targets that call the script:
This makes the KIND dev-cluster workflow discoverable via
make help/ tab completion and keeps the “entrypoint” stable.4) (Recommended) Document the KIND dev loop in README
File:
README.mdAdd a short section like:
5) Add a Mux agent skill for per-workspace KIND clusters
Files:
.mux/skills/kind-dev/SKILL.mdCreate a lightweight Mux skill (docs-only, no bundled references) that agents can load on demand to run the KIND dev loop in parallel across workspaces.
The skill should emphasize:
CLUSTER_NAMEper workspace (recommendcoder-k8s-${MUX_WORKSPACE_NAME})./hack/kind-dev.sh) rather than re-encoding CI steps in agent promptskubectl --context kind-${CLUSTER_NAME} ...) to avoid acting on the wrong clusterSuggested
SKILL.mdskeleton:Bootstrap
./hack/kind-dev.sh up kubectl --context kind-${CLUSTER_NAME} get nodesStart controller (out-of-cluster)
(Optional) In-cluster controller
Demo with k9s
k9s --context kind-${CLUSTER_NAME}Cleanup
Validation (when implementing)
nix develop -c kubectl version --clientnix develop -c kind versionnix develop -c k9s versionbash -n hack/kind-dev.shCLUSTER_NAME=coder-k8s-dev ./hack/kind-dev.sh uptest "$(kubectl config current-context)" = "kind-coder-k8s-dev"kubectl --context kind-coder-k8s-dev get crd codercontrolplanes.coder.comkubectl --context kind-coder-k8s-dev get clusterrole manager-rolekubectl --context kind-coder-k8s-dev -n coder-system get sa coder-k8sCLUSTER_NAME=coder-k8s-dev ./hack/kind-dev.sh load-imagekubectl --context kind-coder-k8s-dev apply -f config/e2e/deployment.yamlkubectl --context kind-coder-k8s-dev -n coder-system wait --for=condition=Available deploy/coder-k8s --timeout=120stest -f .mux/skills/kind-dev/SKILL.mdCLUSTER_NAME=coder-k8s-dev ./hack/kind-dev.sh downGenerated with
mux• Model:openai:gpt-5.3-codex• Thinking:xhigh• Cost:$0.68