Skip to content

Basic Kubernetes Commands

To launch an ad-hoc debugging or exploration session with an interactive terminal:

Terminal window
kubectl run test-session \
--namespace sci-myproject \
--image=ubuntu:22.04 \
--restart=Never \
-it -- /bin/bash

Scientific workloads are defined using declarative YAML manifests.

Save the following as my-pod.yaml:

apiVersion: v1
kind: Pod
metadata:
name: gpu-analysis-test
namespace: sci-myproject
spec:
restartPolicy: OnFailure
containers:
- name: worker
image: registry.berkelium.lbl.gov/sci-als/synchrotron-model:v1
command: ["python", "app/evaluate.py"]
resources:
limits:
cpu: "8"
memory: "32Gi"
nvidia.com/gpu: "1"
requests:
cpu: "4"
memory: "16Gi"
nvidia.com/gpu: "1"

Apply and monitor the pod:

Terminal window
# Submit pod to the cluster
kubectl apply -f my-pod.yaml
# Check status
kubectl get pods -n sci-myproject
# Follow logs in real-time
kubectl logs -f gpu-analysis-test -n sci-myproject

Terminal window
# Get detailed status and scheduling events
kubectl describe pod <pod-name> -n sci-myproject
# Open a shell inside an active container
kubectl exec -it <pod-name> -n sci-myproject -- /bin/bash
# View resource usage (CPU & Memory)
kubectl top pods -n sci-myproject
# Delete a completed or obsolete pod
kubectl delete pod <pod-name> -n sci-myproject