Run Slurm on Kubernetes with the Slinky Operator
Install the Slinky slurm-operator with Helm to run a full Slurm cluster on Kubernetes: Controller, NodeSet, LoginSet, accounting, sbatch and srun jobs.
💡 Quick Answer: Slinky is the SchedMD/NVIDIA project that runs Slurm daemons as Kubernetes custom resources. Install cert-manager, then three Helm charts —
slurm-operator-crds,slurm-operator(namespaceslinky) andslurm(namespaceslurm) — and you getslurmctld,slurmdworkers (a NodeSet),slurmrestd, and optionally login pods andslurmdbd. Users keep usingsbatch,srunandsqueue; Kubernetes handles placement, restarts and rolling updates.
The Problem
HPC and AI training teams think in Slurm: partitions, fair-share, backfill, sbatch scripts that have worked for years. Platform teams want one Kubernetes fleet for everything. Hand-rolling Slurm on Kubernetes (a slurmctld StatefulSet plus a slurmd DaemonSet, as in SLURM and Kubernetes Integration) works, but you own all the glue:
- Static
slurm.conf— every new worker pod needs aNodeName=line and a controller reconfigure - Munge/auth keys — distributed by hand to every pod
- Draining —
kubectl drainevicts a pod mid-job; Slurm doesn’t know the node is going away - Upgrades — rolling
slurmdimages kills running jobs
Slinky’s slurm-operator solves these by modelling each Slurm daemon as a CRD and reconciling Slurm state with Kubernetes state.
The Solution
Architecture
flowchart LR
subgraph slinky["namespace: slinky"]
OP[slurm-operator]
WH[slurm-operator-webhook]
end
subgraph slurm["namespace: slurm"]
CTL["Controller CR<br/>slurm-controller-0<br/>(slurmctld)"]
RA["RestApi CR<br/>slurmrestd"]
ACC["Accounting CR<br/>slurmdbd"]
LS["LoginSet CR<br/>login pods + sshd"]
NS["NodeSet CR<br/>slurm-worker-* (slurmd)"]
DB[(MariaDB)]
end
OP -->|reconciles| CTL & RA & ACC & LS & NS
NS -->|registers dynamic nodes| CTL
LS -->|sbatch / srun| CTL
ACC --> DB
CTL --> ACCCRD (slinky.slurm.net/v1beta1) | Slurm daemon | Notes |
|---|---|---|
Controller | slurmctld | Single pod; HA comes from Kubernetes restarting it on persistent state, not Slurm’s native backup controller |
NodeSet | slurmd | Worker pods; one pod per Kubernetes node is the expected layout. StatefulSet-style replicas or DaemonSet-style via nodeSelector |
LoginSet | sshd + Slurm clients | Optional login nodes, SSSD for LDAP/AD users |
Accounting | slurmdbd | Optional; any MySQL/MariaDB-compatible DB |
RestApi | slurmrestd | REST API, also used for metrics/autoscaling |
Token | — | JWT tokens for slurmrestd clients |
The operator turns on the Slurm features that containerized operation needs:
- Configless mode: workers fetch config from
slurmctld, so no shared filesystem is needed forslurm.conf. - Dynamic nodes: workers register on startup, so scaling a NodeSet needs no
slurm.confedit. auth/slurmwithuse_client_ids: cluster-wide authentication with no per-node identity service (no munge).
ConfigMap and Secret changes are pushed from the controller to every worker without restarting the scheduler. From Slurm 25.11, slurmd enforces cgroup v2 isolation inside its container, so concurrent jobs from different users on one worker are isolated. The reference images (and their Dockerfiles) are a starting point: extend them with your libraries, or build your own as long as they contain a working Slurm install.
Operator v1.1.0 added three things: DaemonSet-style scaling, where a nodeSelector gives a fixed 1:1 worker-to-node mapping; dynamic topology, where workers register the topology of the Kubernetes node they run on; and automatic recreation of worker pods that are healthy but never registered with Slurm.
Step 1: Install cert-manager
The operator’s webhook uses cert-manager for TLS:
helm install cert-manager oci://quay.io/jetstack/charts/cert-manager \
--namespace cert-manager --create-namespace \
--set crds.enabled=true(You can skip it with --set certManager.enabled=false on the operator chart, but then you manage webhook certificates yourself.)
Step 2: Install the CRDs and the operator
# Pin a release; check https://github.com/SlinkyProject/slurm-operator/releases
export SLINKY_VERSION=1.3.0
helm install slurm-operator-crds \
oci://ghcr.io/slinkyproject/charts/slurm-operator-crds \
--version "$SLINKY_VERSION"
helm install slurm-operator \
oci://ghcr.io/slinkyproject/charts/slurm-operator \
--namespace slinky --create-namespace \
--version "$SLINKY_VERSION"
kubectl get pods -n slinky
# slurm-operator-7c9f... 1/1 Running
# slurm-operator-webhook-5d8b... 1/1 RunningTo restrict the operator to specific namespaces, add --set 'operator.namespaces={slurm}' --set 'webhook.namespaces={slurm}'.
Step 3: Deploy a Slurm cluster
The smallest useful cluster is one NodeSet and a default partition:
helm install slurm oci://ghcr.io/slinkyproject/charts/slurm \
--namespace slurm --create-namespace \
--version "$SLINKY_VERSION" \
--set-json 'nodesets={"slinky":{}}' \
--set "partitions.all.enabled=true"For anything real, use a values file:
# slurm-values.yaml
nodesets:
slinky:
replicas: 3
slurmd:
resources:
# Without requests the scheduler packs workers anywhere;
# size slurmd to (almost) the whole node.
requests:
cpu: "15"
memory: 56Gi
limits:
cpu: "15"
memory: 60Gi
partition:
enabled: true
configMap:
State: UP
MaxTime: UNLIMITED
loginsets:
slinky:
enabled: true
replicas: 1
partitions:
all:
enabled: true
controller:
persistence:
enabled: truehelm upgrade --install slurm oci://ghcr.io/slinkyproject/charts/slurm \
--namespace slurm --create-namespace \
--version "$SLINKY_VERSION" \
-f slurm-values.yaml \
--set-file "loginsets.slinky.rootSshAuthorizedKeys=${HOME}/.ssh/id_ed25519.pub"
kubectl get pods -n slurm
# slurm-controller-0 3/3 Running
# slurm-restapi-6f7d... 1/1 Running
# slurm-login-slinky-... 1/1 Running
# slurm-worker-slinky-0 2/2 Running
# slurm-worker-slinky-1 2/2 Running
# slurm-worker-slinky-2 2/2 Running
kubectl get nodesets,loginsets -n slurmStep 4: Log in and run jobs
The LoginSet is exposed as a LoadBalancer Service:
SLURM_LOGIN_HOST=$(kubectl get svc -n slurm slurm-login-slinky \
-o jsonpath='{.status.loadBalancer.ingress[0].ip}')
SLURM_LOGIN_PORT=$(kubectl get svc -n slurm slurm-login-slinky \
-o jsonpath='{.spec.ports[0].port}')
ssh -p "${SLURM_LOGIN_PORT:-22}" root@"${SLURM_LOGIN_HOST}"No LoadBalancer? Tunnel through the API server instead (the login image ships socat):
ssh -o ProxyCommand='kubectl exec -i -n slurm svc/%h -- socat STDIO TCP:localhost:22' \
root@slurm-login-slinkyFrom the login pod it is plain Slurm:
sinfo
# PARTITION AVAIL TIMELIMIT NODES STATE NODELIST
# slinky up infinite 3 idle slinky-[0-2]
# all* up infinite 3 idle slinky-[0-2]
srun -N 3 hostname
sbatch --wrap="sleep 60 && hostname"
squeueYou can also skip the login pod entirely and run clients from the controller container:
kubectl exec -n slurm slurm-controller-0 -c slurmctld -- sinfo
kubectl exec -n slurm slurm-controller-0 -c slurmctld -- \
sbatch --output=/tmp/hello.out --wrap="hostname; date"Step 5: Add accounting (slurmdbd)
Accounting needs a MySQL/MariaDB database. With the MariaDB operator:
apiVersion: v1
kind: Secret
metadata:
name: mariadb-password
namespace: slurm
stringData:
password: change-me
---
apiVersion: k8s.mariadb.com/v1alpha1
kind: MariaDB
metadata:
name: mariadb
namespace: slurm
spec:
rootPasswordSecretKeyRef:
name: mariadb-password
key: password
database: slurm_acct_db
username: slurm
passwordSecretKeyRef:
name: mariadb-password
key: password
storage:
size: 16GiThen enable Accounting in the Slurm chart:
accounting:
enabled: true
storageConfig:
host: mariadb
port: 3306
database: slurm_acct_db
username: slurm
passwordKeyRef:
name: mariadb-password
key: passwordhelm upgrade slurm oci://ghcr.io/slinkyproject/charts/slurm -n slurm \
--version "$SLINKY_VERSION" -f slurm-values.yaml
# then, from the login pod:
sacctStep 6: Scale and drain safely
# Scale workers like any other workload
kubectl scale nodeset slurm-worker-slinky -n slurm --replicas=5
# Draining a Kubernetes node drains the Slurm node first
kubectl drain worker-node-07 --ignore-daemonsets
# → Slurm node goes DRAIN with the drain reason; running jobs finishScale-in and rolling image updates follow the same rule: the operator drains the Slurm node before deleting its pod, preferring pods whose jobs finish soonest. Slurm node states (idle, allocated, mixed, drain, down…) are mirrored as pod conditions, so kubectl describe pod slurm-worker-slinky-0 tells you what Slurm thinks.
Common Issues
slurmd pods stuck in Init
The worker waits for slurmctld to be reachable at slurm-controller.slurm:6817. A few minutes on first install is normal; longer usually means the controller pod is crash-looping — check kubectl logs -n slurm slurm-controller-0 -c slurmctld.
Insane message length or auth failures
slurmctld and slurmd are on different Slurm versions, or the slurm.key secret changed after workers started. Keep every image on the same tag and restart workers after rotating keys:
kubectl delete pod -n slurm -l app.kubernetes.io/name=slurmdWorkers all land on one node
slurmd has no resource requests by default. Set requests close to the node’s allocatable size (or use DaemonSet-style scaling with a nodeSelector) so you get one worker per Kubernetes node.
Old Slinky (0.x) leftovers
The 0.x clusters.slinky.slurm.net CRD is defunct. Uninstall the old charts and delete the old CRDs before installing 1.x.
Best Practices
- Pin
--versionon all three charts and upgrade them in order: CRDs → operator →slurm - Keep Slurm ≥ 25.11 — required by current operator releases and needed for OpenMetrics-based autoscaling
- Size
slurmdto the node — Slurm schedules inside the pod’s cgroup; a tiny pod means a tiny Slurm node - Use shared storage (RWX PVC for
/homeand datasets) on both login and worker pods - Use SSSD on login pods for real users instead of root + SSH keys
- Protect workers with PDBs (on by default via
workloadDisruptionProtection) so voluntary evictions can’t kill jobs
Key Takeaways
- Slinky’s slurm-operator turns Slurm daemons into CRDs:
Controller,NodeSet,LoginSet,Accounting,RestApi - Three Helm charts — CRDs, operator, cluster — plus cert-manager is the whole install
- Configless + dynamic nodes means scaling a NodeSet never touches
slurm.conf kubectl draindrains Slurm first, so maintenance no longer kills jobs- Users keep
sbatch/srun; for GPUs and autoscaling see Slurm GPU workloads on Kubernetes with Slinky, and for OpenShift see Slinky on OpenShift
Book by Grzegorz Stencel & Luca Berton
Kubernetes Recipes
- Paperback · eBook
- Apress
- 750 pages
100+ production-ready patterns with detailed explanations, best practices, and copy-paste YAML. Everything in one place.
Book by Grzegorz Stencel & Luca Berton · Apress
Kubernetes RecipesGet the book