Interactive Pods & Long-Idle Guidelines
Interactive pods enable live development, notebook prototyping, and terminal access to GPU hardware.
Launching an Interactive GPU Pod
Section titled “Launching an Interactive GPU Pod”Because GPU scheduling requires specifying resource limits (nvidia.com/gpu), you can launch an interactive session using either a declarative YAML manifest (recommended) or a one-liner with --overrides.
Option A: Using a YAML Manifest (Recommended)
Section titled “Option A: Using a YAML Manifest (Recommended)”Save the following as dev-session.yaml:
apiVersion: v1kind: Podmetadata: name: dev-session namespace: <your-namespace>spec: restartPolicy: Never containers: - name: dev-container image: pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime stdin: true tty: true command: ["/bin/bash"] resources: limits: nvidia.com/gpu: "1" cpu: "8" memory: "32Gi"Apply and attach to the session:
# Launch the podkubectl apply -f dev-session.yaml
# Attach to the running shellkubectl attach -it dev-session -n <your-namespace>
# Or exec an independent interactive bash shellkubectl exec -it dev-session -n <your-namespace> -- /bin/bashOption B: One-Liner with kubectl run and --overrides
Section titled “Option B: One-Liner with kubectl run and --overrides”Since kubectl run does not have a native --limits flag, pass container resource limits using --overrides:
kubectl run dev-session \ --namespace <your-namespace> \ --image=pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime \ --restart=Never \ --rm -it \ --overrides='{ "spec": { "containers": [{ "name": "dev-session", "image": "pytorch/pytorch:2.3.0-cuda12.1-cudnn8-runtime", "stdin": true, "tty": true, "resources": { "limits": { "nvidia.com/gpu": "1", "cpu": "8", "memory": "32Gi" } } }] } }' -- /bin/bashOption C: Quick CPU-Only Interactive Shell
Section titled “Option C: Quick CPU-Only Interactive Shell”For lightweight debugging or scripting that doesn’t require GPUs:
kubectl run dev-session \ --namespace <your-namespace> \ --image=ubuntu:22.04 \ --restart=Never \ --rm -it -- /bin/bashBest Practices for Interactive Work
Section titled “Best Practices for Interactive Work”- Clean up when done: Do not leave idle GPU pods running overnight without computations. When finished, exit and delete the pod:
Terminal window kubectl delete pod dev-session -n <your-namespace> - Mount Persistent Storage: Always mount a CephFS PVC so your notebooks, code edits, and conda environments persist across pod restarts.
- Port Forwarding for Web UIs: If your pod runs TensorBoard, Streamlit, or JupyterLab on port
8888:OpenTerminal window kubectl port-forward dev-session 8888:8888 -n <your-namespace>http://localhost:8888on your local laptop to access the interactive web interface securely via encrypted SSH/tunnel.
