Dynamically share cluster nodes between Slurm HPC and Kubernetes to eliminate idle-resource waste.
With static allocation, each Slurm Pod permanently reserves resources — even when idle — causing fragmentation. The ack-slurm-operator colocated scheduling solution addresses this by letting Slurm jobs and Kubernetes Pods share the same physical nodes dynamically. SlurmCopilot, running in the Kubernetes cluster, coordinates resource allocation with Slurm in real time so both schedulers use the same capacity without conflicts.
How it works
The following figure shows how colocated scheduling works.

Key components
Component | Description |
SlurmOperator | Launches a containerized Slurm cluster. Worker Pods run exclusively on dedicated cluster nodes; other Slurm system components are scheduled on random nodes. |
SlurmCopilot | Coordinates resources with Slurmctld via a cluster token. When an AdmissionCheck is added to a GenericNode, updates available resources in Slurmctld, writes status back to the GenericNode, and notifies the ACK scheduler. |
Slurmctld | Central Slurm manager daemon. Monitors resources and jobs, schedules jobs, and allocates resources. Supports a backup for high availability. |
GenericNode | Custom resource acting as a resource ledger between Kubernetes and Slurm. Before placing a Pod, the ACK scheduler adds an AdmissionCheck to the GenericNode to confirm resources with Slurm. |
Slurmd | Slurm node daemon. Runs on each compute node, executes jobs, and reports status to Slurmctld. |
Slurmdbd | Slurm database daemon for job accounting. Optional — accounting data can be stored in files instead. |
Slurmrestd | Slurm REST API daemon. Optional — you can use CLI tools instead. |
By default, Slurmctld auto-generates a JWT token on startup and writes it to a Kubernetes Secret via kubectl. To override, use a custom startup script or revoke the Secret update permission, then update the token in theack-slurm-jwt-tokenSecret in theack-slurm-operatornamespace. In theDatafield, use the cluster name as the key and the Base64-encoded token (base64 --wrap=0) as the value.
Static allocation vs. colocated scheduling
The following table compares the two approaches.
Static allocation | Colocated scheduling |
SlurmCopilot uses the OpenAPI to communicate with Slurm, so colocated scheduling also works with non-containerized clusters. See Extend colocated scheduling to non-containerized clusters.
Prerequisites
Before you begin:
An ACK cluster running Kubernetes v1.26 or later. See Add GPU nodes to a cluster and Upgrade a cluster
Helm installed and configured
Install ack-slurm-operator
Log on to the ACK console and click your cluster name.
Install ack-slurm-operator. Leave Application Name and Namespace blank, then click Next. In the Confirm dialog box, click Yes to use the default name (
ack-slurm-operator) and namespace (ack-slurm-operator).
Set Chart Version to the latest version,
enableCopilottotrue, andwatchNamespacetodefault(or a custom namespace). Click OK.
(Optional) To update ack-slurm-operator: on the Cluster Information page, click the Applications > Helm tab, find ack-slurm-operator, and click Update.

Install and configure ack-slurm-cluster
Deploy the SlurmCluster Helm chart. It creates all required resources — RBAC, ConfigMaps, Secrets, and the SlurmCluster resource — from a single values.yaml file.
Step 1: Pull the Helm chart
Add the Alibaba Cloud Helm repository.
helm repo add aliyun https://aliacs-app-catalog.oss-cn-hangzhou.aliyuncs.com/charts-incubator/Pull and unpack the chart. This creates an
ack-slurm-clusterdirectory with all chart files and templates.helm pull aliyun/ack-slurm-cluster --untar=trueOpen
values.yamlto configure the chart.cd ack-slurm-cluster vi values.yaml
Step 4: Install the chart
Install the chart. If already installed, run helm upgrade instead and delete existing Pods and the Slurmctld StatefulSet to apply changes.
cd ..
helm install my-slurm-cluster ack-slurm-clusterVerify installation
Confirm the chart is deployed.
helm listExpected output:
NAME NAMESPACE REVISION UPDATED STATUS CHART APP VERSION ack-slurm-cluster default 1 2024-07-19 14:47:58.126357 +0800 CST deployed ack-slurm-cluster-2.0.0 2.0.0Confirm all Pods are running.
kubectl get podExpected output: one worker and three control plane Pods running.
NAME READY STATUS RESTARTS AGE slurm-test-slurmctld-dlncz 1/1 Running 0 3h49m slurm-test-slurmdbd-8f75r 1/1 Running 0 3h49m slurm-test-slurmrestd-mjdzt 1/1 Running 0 3h49m slurm-test-worker-cpu-0 1/1 Running 0 166mConfirm Slurmdbd started correctly.
kubectl exec slurm-test-slurmdbd-8f75r cat /var/log/slurmdbd.log | headExpected output:
kubectl exec [POD] [COMMAND] is DEPRECATED and will be removed in a future version. Use kubectl exec [POD] -- [COMMAND] instead. [2024-07-22T19:52:55.727] accounting_storage/as_mysql: _check_mysql_concat_is_sane: MySQL server version is: 8.0.34 [2024-07-22T19:52:55.737] error: Database settings not recommended values: innodb_lock_wait_timeout [2024-07-22T19:52:56.089] slurmdbd version 23.02.7 started
Verify colocated scheduling
Check the GenericNode to view resource allocation across Slurm and Kubernetes.
kubectl get genericnodeExpected output:
NAME CLUSTERNAME ALIAS TYPE ALLOCATEDRESOURCES cn-hongkong.10.1.0.19 slurm-test-worker-cpu-0 Slurm [{"allocated":{"cpu":"0","memory":"0"},"type":"Slurm"},{"allocated":{"cpu":"1735m","memory":"2393Mi"},"type":"Kubernetes"}]Submit a Slurm job and scale a Kubernetes Deployment to see updated GenericNode allocations.
[root@iZj6c1wf3c25dbynbna3qgZ ~]# kubectl exec slurm-test-slurmctld-dlncz -- nohup srun --cpus-per-task=3 --mem=4000 --gres=k8scpu:3,k8smemory:4000 sleep inf & [1] 4132674 [root@iZj6c1wf3c25dbynbna3qgZ ~]# kubectl scale deployment nginx-deployment-basic --replicas 2 deployment.apps/nginx-deployment-basic scaled [root@iZj6c1wf3c25dbynbna3qgZ ~]# kubectl get genericnode NAME CLUSTERNAME ALIAS TYPE ALLOCATEDRESOURCES cn-hongkong.10.1.0.19 slurm-test-worker-cpu-0 Slurm [{"allocated":{"cpu":"3","memory":"4000Mi"},"type":"Slurm"},{"allocated":{"cpu":"2735m","memory":"3417Mi"},"type":"Kubernetes"}]Submit a second Slurm job. With all resources allocated, it enters Pending (PD) state.
[root@iZj6c1wf3c25dbynbna3qgZ ~]# kubectl exec slurm-test-slurmctld-dlncz -- nohup srun --cpus-per-task=3 --mem=4000 sleep inf & [2] 4133454 [root@iZj6c1wf3c25dbynbna3qgZ ~]# srun: job 2 queued and waiting for resources [root@iZj6c1wf3c25dbynbna3qgZ ~]# kubectl exec slurm-test-slurmctld-dlncz -- squeue JOBID PARTITION NAME USER ST TIME NODES NODELIST(REASON) 2 debug sleep root PD 0:00 1 (Resources) 1 debug sleep root R 2:34 1 slurm-test-worker-cpu-0
Thesruncommand in step 3 omits--gresbecause thejob_resource_completionplug-in auto-fills GRES from CPU and memory requests. Without this plug-in, add--gres=k8scpu:3,k8smemory:4000manually.
Extend colocated scheduling to non-containerized clusters
SlurmCopilot communicates with Slurm via the OpenAPI, so it also supports non-containerized Slurm clusters.
In a non-containerized setup, create these Kubernetes resources manually, in addition to the JWT token.
Create a Service for each Slurm cluster. SlurmCopilot sends OpenAPI requests to
${.metadata.name}.${.metadata.namespace}.svc.cluster.local:${.spec.ports[0].port}. The Service name must be${slurmCluster}-slurmrestd, where${slurmCluster}matches the value specified in the GenericNode.apiVersion: v1 kind: Service metadata: name: slurm-slurmrestd namespace: default spec: ports: - name: slurmrestd port: 8080 protocol: TCP targetPort: 8080Create a DNS record that resolves
${.metadata.name}.${.metadata.namespace}.svc.cluster.local:${.spec.ports[0].port}to the Slurmrestd address.Create GenericNode resources for Slurm nodes. GenericNode maps a Kubernetes node to a Slurm node via an alias. The
namemust match the Kubernetes node name,.spec.aliasmust match the Slurm node name, and the labelskai.alibabacloud.com/cluster-nameandkai.alibabacloud.com/cluster-namespacemust match the Service.apiVersion: kai.alibabacloud.com/v1alpha1 kind: GenericNode metadata: labels: kai.alibabacloud.com/cluster-name: slurm-test kai.alibabacloud.com/cluster-namespace: default name: cn-hongkong.10.1.0.19 spec: alias: slurm-test-worker-cpu-0 type: Slurm
Summary
With colocated scheduling, Slurm schedules HPC jobs and Kubernetes orchestrates containerized workloads on the same cluster. This lets you leverage the Kubernetes ecosystem, including Helm charts, CI/CD pipelines, and monitoring tools, while consolidating workloads into a single cluster for more efficient resource utilization.