Run devbox with Kubernetes
pod.yaml runs devbox as a single non-root pod that
sleeps until you open a shell in it with kubectl exec.
- Images
- GHCR
ghcr.io/hambn/devbox - Docker Hub
docker.io/hambn/devbox
- GHCR
- Use case
- Disposable cluster development pod
Prerequisites
- A Kubernetes cluster and
kubectlconfigured for it.
Open a shell
Shell
kubectl apply -f pod.yaml
kubectl wait --for=condition=Ready pod/devbox
kubectl exec -it devbox -- zsh -lCopy files in and out with kubectl cp:
Shell
kubectl cp ./src devbox:/workspace/src
kubectl cp devbox:/workspace/out ./outWorkspace
/workspace is an emptyDir and is deleted with the pod. Replace it with a
PersistentVolumeClaim to keep your work, or use the Helm recipe.
The pod runs as UID 1000 with every capability dropped and
allowPrivilegeEscalation: false, so sudo and ping fail. No Docker daemon runs in
the pod; set DOCKER_HOST to use a remote one.
Files
pod.yamldefines the pod, its security context, and resource limits.
Cleanup
Shell
kubectl delete -f pod.yamlFile contents
pod.yaml38 lines
# kubectl apply -f pod.yaml && kubectl exec -it devbox -- zsh -l
apiVersion: v1
kind: Pod
metadata:
name: devbox
labels:
app.kubernetes.io/name: devbox
spec:
securityContext:
runAsNonRoot: true
runAsUser: 1000
runAsGroup: 1000
fsGroup: 1000
seccompProfile:
type: RuntimeDefault
containers:
- name: devbox
image: ghcr.io/hambn/devbox:ubuntu-full
imagePullPolicy: Always
command: ["sleep", "infinity"]
workingDir: /workspace
securityContext:
allowPrivilegeEscalation: false
capabilities:
drop: ["ALL"]
resources:
requests:
cpu: 250m
memory: 512Mi
limits:
cpu: "2"
memory: 4Gi
volumeMounts:
- name: workspace
mountPath: /workspace
volumes:
- name: workspace
emptyDir: {}