Spin up a minimal Kubernetes cluster inside a Coder workspace. Uses k3s with sudo (no systemd).
- Containers won't actually run. The OCI runtime fails with
unsafe procfsbecause the workspace itself is a container. Pods stay inContainerCreating. Fine for Terraform state bugs, k8s API-level issues, and anything that doesn't need running workloads. - Ephemeral — k3s state is lost on workspace restart.
# 1. Install k3s binary
curl -sfL https://get.k3s.io | \
INSTALL_K3S_EXEC="--disable=traefik --write-kubeconfig-mode=644" sh - 2>&1 | tail -3
# Ignore the systemd error — expected in containers.
# 2. Start k3s manually (no systemd)
sudo nohup k3s server \
--disable=traefik \
--write-kubeconfig-mode=644 \
> /tmp/k3s.log 2>&1 &
# 3. Wait for ready (~5-10s)
for i in $(seq 1 30); do
sudo k3s kubectl get nodes 2>/dev/null | grep -q Ready && break
sleep 2
done
# 4. Set up kubeconfig for non-root use
mkdir -p ~/.kube
sudo cp /etc/rancher/k3s/k3s.yaml ~/.kube/config
sudo chown $(id -u):$(id -g) ~/.kube/config
export KUBECONFIG=~/.kube/config
# 5. Verify
kubectl get nodesTF_VERSION=1.13.0
cd /tmp
wget -q "https://releases.hashicorp.com/terraform/${TF_VERSION}/terraform_${TF_VERSION}_linux_amd64.zip"
unzip -o "terraform_${TF_VERSION}_linux_amd64.zip" -d "/tmp/tf${TF_VERSION//./}"
"/tmp/tf${TF_VERSION//./}/terraform" versionk3s and its state are gone. Re-run the setup steps. Terraform state files on the workspace filesystem persist.
| Coder version | Bundled Terraform |
|---|---|
| v2.28.7 | 1.13.0 |
| main (HEAD) | 1.14.5 |
| pre-identity | ≤ 1.11.x |