Skip to content

Dev pod

An interactive Pod you apply with kubectl and reach through port-forward, with no Git, ArgoCD, Service or Ingress. Use it for work you will delete within hours or days. For anything long-lived, use a Long-running service. The same manifest works for RStudio Server or code-server: change the image and port.

Save it outside your workload repo and replace <tenant>.

dev-pod.yaml
apiVersion: v1
kind: Pod
metadata:
name: jupyter
namespace: <tenant>-dev
labels:
app: jupyter
spec:
priorityClassName: uber-user-significant # never preempts other Pods
securityContext: # PodSecurity restricted, enforced by Kyverno
runAsNonRoot: true
runAsUser: 1000 # jovyan
fsGroup: 100 # jovyan's group; makes a Cinder PVC writable
fsGroupChangePolicy: OnRootMismatch
seccompProfile:
type: RuntimeDefault
containers:
- name: notebook
image: quay.io/jupyter/minimal-notebook:2024-08-19
ports:
- containerPort: 8888
securityContext:
allowPrivilegeEscalation: false
readOnlyRootFilesystem: true # optional hardening; needs the writable mounts below
capabilities:
drop: [ALL]
resources:
requests:
cpu: 500m
memory: 1Gi
limits:
cpu: 2
memory: 4Gi
volumeMounts:
- name: home
mountPath: /home/jovyan
- name: tmp
mountPath: /tmp
volumes:
- name: home
emptyDir: {} # deleted with the Pod
- name: tmp
emptyDir: {}

To keep notebooks after the Pod is deleted, create a PVC (Persistent volumes) and use it for home:

- name: home
persistentVolumeClaim:
claimName: jupyter-home

A fresh Cinder volume is root:root 0755. The fsGroup line is what lets Jupyter, running as UID 1000, write to it.

Terminal window
kubectl create namespace <tenant>-dev # if it doesn't exist yet
kubectl apply -f dev-pod.yaml
kubectl wait --for=condition=Ready pod/jupyter -n <tenant>-dev --timeout=5m
kubectl logs jupyter -n <tenant>-dev | grep token=
kubectl port-forward -n <tenant>-dev pod/jupyter 8888:8888

Open http://localhost:8888/lab?token=<token>. If the port-forward drops, run it again; the session lives as long as the Pod.

Download anything you want to keep (File → Download), then:

Terminal window
kubectl delete pod jupyter -n <tenant>-dev

The emptyDir volumes and their contents go with the Pod. A PVC stays until you delete it.

SymptomCause and fix
kubectl apply fails with a validate.kyverno.svc-fail PodSecurity denialA required securityContext field is missing. Restore it from the manifest above.
Jupyter reports Permission denied/home/jovyan isn’t writable: check the home mount, and fsGroup if it is a PVC.

For other messages, see the Troubleshooting index.