# Transcript for 12-kubernetes-for-machine-learning/03-batch-and-gang-scheduling.md. # Tier A: kind. Kubernetes v1.37.0 server, kubectl v1.37.2. # Recorded on a shared lab cluster; its node name differs from the one a kind # cluster on a reader's machine prints. # The run used the scratch namespace p12-03-bookstore-ml where the chapter says # bookstore-ml. The copy of gpu-quota-probe.yaml was rewritten to that namespace # and nothing else changed. # The Kueue and JobSet installs and the gang run are in the last section, # recorded later by examples/security-lab/labs/12-03-kueue.sh with # LAB_PREFIX=p12-finish: namespaces p12-finish-jobset, p12-finish-kueue and # p12-finish-ml stand in for jobset-system, kueue-system and bookstore-ml, and # the lab's Kueue objects carry p12-finish-ml where the chapter's carry # bookstore-ml. The charts were pinned at JobSet 0.11.1 and Kueue 0.17.0, and # the run took the lab's heavy-install lock. The lab removed both charts, the # namespaces and the CRDs at the end. # Commands are shown as "$ ..." lines. "[exit N]" lines give the exit code of # the command above them. $ kubectl get --raw /version { "major": "1", "minor": "37", "emulationMajor": "1", "emulationMinor": "37", "minCompatibilityMajor": "1", "minCompatibilityMinor": "36", "gitVersion": "v1.37.0", "gitCommit": "f54c212e3a2f75d674b717a9b29052b20b60aefc", "gitTreeState": "clean", "buildDate": "2026-08-26T10:44:25Z $ kubectl api-resources --api-group=scheduling.k8s.io NAME SHORTNAMES APIVERSION NAMESPACED KIND priorityclasses pc scheduling.k8s.io/v1 false PriorityClass $ docker run --rm busybox@sha256:73aaf090f3d85aa34ee199857f03fa3a95c8ede2ffd4cc2cdb5b94e566b11662 id -u 0 $ kubectl create namespace p12-03-bookstore-ml namespace/p12-03-bookstore-ml created $ kubectl label namespace p12-03-bookstore-ml (ch.01 labels) --overwrite namespace/p12-03-bookstore-ml labeled $ kubectl get ns p12-03-bookstore-ml -o jsonpath labels | grep pod-security "pod-security.kubernetes.io/audit":"restricted" "pod-security.kubernetes.io/audit-version":"latest" "pod-security.kubernetes.io/enforce":"restricted" "pod-security.kubernetes.io/enforce-version":"latest" "pod-security.kubernetes.io/warn":"restricted" "pod-security.kubernetes.io/warn-version":"latest"} $ kubectl create -n p12-03-bookstore-ml quota gpu-quota --hard=requests.nvidia.com/gpu=4 | kubectl apply -f - resourcequota/gpu-quota created $ kubectl get resourcequota -n p12-03-bookstore-ml NAME REQUEST LIMIT AGE gpu-quota requests.nvidia.com/gpu: 0/4 1s $ kubectl apply --dry-run=server -f gpu-quota-probe.yaml (5 GPUs: DELIBERATE denial) Error from server (Forbidden): error when creating "gpu-quota-probe.yaml": pods "gpu-quota-probe" is forbidden: exceeded quota: gpu-quota, requested: requests.nvidia.com/gpu=5, used: requests.nvidia.com/gpu=0, limited: requests.nvidia.com/gpu=4 [exit 1] $ kubectl apply --dry-run=server -f gpu-quota-probe.yaml (4 GPUs: within quota) pod/gpu-quota-probe created (server dry run) [exit 0] $ kubectl get resourcequota gpu-quota -n p12-03-bookstore-ml (dry runs charge nothing) NAME REQUEST LIMIT AGE gpu-quota requests.nvidia.com/gpu: 0/4 1s $ kubectl delete namespace p12-03-bookstore-ml (cleanup of the namespace this run created) namespace "p12-03-bookstore-ml" deleted ## Revision run: the ServiceAccount, the quota probe again, and the Kueue render checks # The ServiceAccount file and the probe were applied in a new scratch namespace, p12-03-bookstore-ml, # which was deleted at the end of the run. The 5-GPU copy of gpu-quota-probe.yaml differs from # the 4-GPU copy only in its two quantities. The Kueue checks render the pinned chart with the # repository values, from the full-guide directory, and need no cluster. $ kubectl create namespace p12-03-bookstore-ml namespace/p12-03-bookstore-ml created $ kubectl label namespace p12-03-bookstore-ml (restricted, enforce audit warn, version latest) namespace/p12-03-bookstore-ml labeled $ kubectl apply -f recommender-batch-serviceaccount.yaml (namespace rewritten to p12-03-bookstore-ml) serviceaccount/recommender-batch created $ kubectl create -n p12-03-bookstore-ml quota gpu-quota --hard=requests.nvidia.com/gpu=4 | kubectl apply -f - resourcequota/gpu-quota created $ kubectl get resourcequota -n p12-03-bookstore-ml NAME REQUEST LIMIT AGE gpu-quota requests.nvidia.com/gpu: 0/4 1s $ kubectl apply --dry-run=server -f gpu-quota-probe.yaml (5 GPUs: DELIBERATE denial) Error from server (Forbidden): error when creating "gpu-quota-probe.yaml": pods "gpu-quota-probe" is forbidden: exceeded quota: gpu-quota, requested: requests.nvidia.com/gpu=5, used: requests.nvidia.com/gpu=0, limited: requests.nvidia.com/gpu=4 [exit 1] $ kubectl apply --dry-run=server -f gpu-quota-probe.yaml (4 GPUs: within quota) pod/gpu-quota-probe created (server dry run) [exit 0] $ kubectl get resourcequota gpu-quota -n p12-03-bookstore-ml (dry runs charge nothing) NAME REQUEST LIMIT AGE gpu-quota requests.nvidia.com/gpu: 0/4 1s $ kubectl apply --dry-run=server -f sa-missing-probe.yaml (a missing ServiceAccount) Error from server (Forbidden): error when creating "sa-missing-probe.yaml": pods "gpu-quota-probe" is forbidden: error looking up service account p12-03-bookstore-ml/recommender-missing: serviceaccount "recommender-missing" not found [exit 1] $ kubectl delete namespace p12-03-bookstore-ml (cleanup of the namespace this run created) namespace "p12-03-bookstore-ml" deleted $ helm template kueue oci://registry.k8s.io/kueue/charts/kueue --version 0.17.0 \ -n kueue-system -f examples/bookstore/ml/batch/kueue-values.yaml \ | grep -A3 -E "name: m(pod|deployment|statefulset|job)\.kb\.io" name: mdeployment.kb.io failurePolicy: Ignore namespaceSelector: matchLabels: -- name: mjob.kb.io namespaceSelector: matchLabels: app.kubernetes.io/part-of: bookstore-ml -- name: mpod.kb.io failurePolicy: Ignore namespaceSelector: matchLabels: -- name: mstatefulset.kb.io failurePolicy: Ignore namespaceSelector: matchLabels: $ helm template kueue oci://registry.k8s.io/kueue/charts/kueue --version 0.17.0 \ -n kueue-system -f examples/bookstore/ml/batch/kueue-values.yaml \ | grep -A4 "waitForPodsReady:" waitForPodsReady: blockAdmission: true recoveryTimeout: 3m timeout: 5m webhook: ## Install run: JobSet 0.11.1 and Kueue 0.17.0, the unlabelled Job, the gang, and removal ## step 1: neither Kueue nor JobSet is installed $ kubectl get crd -o name | grep -c -E 'kueue|jobset' 0 ## step 2: namespaces, labelled restricted before anything is installed $ kubectl create namespace p12-finish-jobset namespace/p12-finish-jobset created $ kubectl create namespace p12-finish-kueue namespace/p12-finish-kueue created $ kubectl create namespace p12-finish-ml namespace/p12-finish-ml created $ kubectl label namespace p12-finish-ml app.kubernetes.io/part-of=bookstore-ml namespace/p12-finish-ml labeled ## step 3: the pinned charts $ helm install jobset oci://registry.k8s.io/jobset/charts/jobset --version 0.11.1 -n p12-finish-jobset --wait (image pinned by digest) NAME: jobset NAMESPACE: p12-finish-jobset STATUS: deployed $ helm install kueue oci://registry.k8s.io/kueue/charts/kueue --version 0.17.0 -n p12-finish-kueue --wait -f examples/bookstore/ml/batch/kueue-values.yaml NAME: kueue NAMESPACE: p12-finish-kueue STATUS: deployed $ kubectl get pods -n p12-finish-jobset NAME READY PHASE jobset-controller-86d78b955-ztk68 true Running $ kubectl get pods -n p12-finish-kueue NAME READY PHASE kueue-controller-manager-577dfc8464-t8sx7 true Running ## step 4: the queue objects and the ServiceAccount $ kubectl apply -f kueue-resourceflavor.yaml (namespace p12-finish-ml) resourceflavor.kueue.x-k8s.io/p12-finish-ml-flavor created $ kubectl apply -f kueue-clusterqueue.yaml (namespace p12-finish-ml) clusterqueue.kueue.x-k8s.io/p12-finish-ml-cq created $ kubectl apply -f kueue-localqueue.yaml (namespace p12-finish-ml) localqueue.kueue.x-k8s.io/p12-finish-ml-lq created $ kubectl apply -f recommender-batch-serviceaccount.yaml (namespace p12-finish-ml) serviceaccount/recommender-batch created $ kubectl get clusterqueue p12-finish-ml-cq NAME COHORT PENDING WORKLOADS p12-finish-ml-cq 0 ## step 5: a Job with no queue label $ kubectl apply -f unlabelled-probe.yaml (namespace p12-finish-ml) job.batch/unlabelled-probe created $ kubectl get job unlabelled-probe -n p12-finish-ml -o jsonpath='{.spec.suspend}' true $ kubectl get pods -n p12-finish-ml -l job-name=unlabelled-probe No resources found in p12-finish-ml namespace. $ kubectl delete job unlabelled-probe -n p12-finish-ml job.batch "unlabelled-probe" deleted from p12-finish-ml namespace ## step 6: the two-worker gang $ kubectl apply -f recommender-jobset.yaml (namespace p12-finish-ml) jobset.jobset.x-k8s.io/recommender-train created $ kubectl wait --for=condition=Completed jobset/recommender-train -n p12-finish-ml --timeout=240s jobset.jobset.x-k8s.io/recommender-train condition met $ kubectl get workloads.kueue.x-k8s.io -n p12-finish-ml NAME QUEUE RESERVED IN ADMITTED FINISHED AGE jobset-recommender-train-63e35 p12-finish-ml-lq p12-finish-ml-cq True True 27s $ kubectl get pods -n p12-finish-ml -l app.kubernetes.io/component=recommender-train -o custom-columns=NAME:.metadata.name,PHASE:.status.phase,STARTED:.status.startTime NAME PHASE STARTED recommender-train-worker-0-0-x4zgh Succeeded 2026-10-31T08:05:11Z recommender-train-worker-0-1-cnscw Succeeded 2026-10-31T08:05:11Z $ kubectl get jobset recommender-train -n p12-finish-ml NAME TERMINALSTATE RESTARTS COMPLETED SUSPENDED AGE recommender-train Completed 0 True false 27s ## step 7: quota below what the gang needs, then restored $ kubectl delete jobset recommender-train -n p12-finish-ml jobset.jobset.x-k8s.io "recommender-train" deleted from p12-finish-ml namespace $ kubectl patch clusterqueue p12-finish-ml-cq (cpu nominalQuota to 0) clusterqueue.kueue.x-k8s.io/p12-finish-ml-cq patched $ kubectl apply -f recommender-jobset.yaml (namespace p12-finish-ml) jobset.jobset.x-k8s.io/recommender-train created $ kubectl get workloads.kueue.x-k8s.io -n p12-finish-ml NAME QUEUE RESERVED IN ADMITTED FINISHED AGE jobset-recommender-train-02aa0 p12-finish-ml-lq 15s $ kubectl get pods -n p12-finish-ml -l app.kubernetes.io/component=recommender-train No resources found in p12-finish-ml namespace. $ kubectl patch clusterqueue p12-finish-ml-cq (cpu nominalQuota back to 4) clusterqueue.kueue.x-k8s.io/p12-finish-ml-cq patched $ kubectl wait --for=condition=Completed jobset/recommender-train -n p12-finish-ml --timeout=240s jobset.jobset.x-k8s.io/recommender-train condition met ## step 8: remove everything, CRDs included $ kubectl delete jobset,localqueue --all -n p12-finish-ml; kubectl delete clusterqueue,resourceflavor (the lab's two) jobset.jobset.x-k8s.io "recommender-train" deleted from p12-finish-ml namespace localqueue.kueue.x-k8s.io "p12-finish-ml-lq" deleted from p12-finish-ml namespace clusterqueue.kueue.x-k8s.io "p12-finish-ml-cq" deleted resourceflavor.kueue.x-k8s.io "p12-finish-ml-flavor" deleted $ helm uninstall kueue -n p12-finish-kueue; helm uninstall jobset -n p12-finish-jobset release "kueue" uninstalled release "jobset" uninstalled $ kubectl delete namespace p12-finish-ml p12-finish-kueue p12-finish-jobset --wait=true namespace "p12-finish-ml" deleted namespace "p12-finish-kueue" deleted namespace "p12-finish-jobset" deleted $ kubectl get crd -o name | grep -E 'kueue|jobset' (what the uninstalls left behind) customresourcedefinition.apiextensions.k8s.io/jobsets.jobset.x-k8s.io $ kubectl delete (each CRD listed above) customresourcedefinition.apiextensions.k8s.io "jobsets.jobset.x-k8s.io" deleted $ kubectl get crd -o name | grep -c -E 'kueue|jobset' 0 $ kubectl get validatingwebhookconfiguration,mutatingwebhookconfiguration -o name | grep -c -E 'kueue|jobset' 0 $ kubectl get clusterrole -o name | grep -c -E 'kueue|jobset' 0