In remote direct memory access (RDMA) shared mode, multiple pods share the same physical RDMA NIC. Use shared mode for workloads that do not require strict device isolation.
Prerequisites
An ACK managed Pro cluster with Lingjun nodes added. For more information, see Create and manage a Lingjun node pool.
A Lingjun node equipped with a physical RDMA NIC, with the NIC driver running as expected. For more information, see Install the RDMA NIC driver.
The RDMA device plugin add-on installed. For more information, see RDMA overview.
Check the RDMA resource on the node
The RDMA device plugin add-on registers each physical RDMA NIC as 1,000 rdma/hca virtual resources and allocates them to pods on demand. After you install the add-on, run the following command to check whether the node provides the rdma/hca resource:
kubectl get node <node-name> -oyamlExpected output:
...
allocatable:
cpu: 189280m
rdma/hca: 1k
capacity:
cpu: "192"
rdma/hca: 1k
...Deploy a workload that uses RDMA
Select a mode based on your network and isolation requirements.
Scenario 1: Use RDMA in hostNetwork mode
In hostNetwork mode, a pod directly uses the network of the host node. This mode suits scenarios that require the highest network performance.
If the non-hostNetwork mode switch of the RDMA device plugin add-on is disabled (the configuration item is set to False), you must configure hostNetwork: true to use RDMA.
apiVersion: batch/v1
kind: Job
metadata:
name: rdma-hostnetwork-test
spec:
parallelism: 1
template:
spec:
hostNetwork: true
tolerations:
- operator: Exists
containers:
- name: rdma-test
image: "<image>"
command:
- sh
- -c
- |
python /workspace/benchmark.py
resources:
limits:
nvidia.com/gpu: 8
rdma/hca: 1
workingDir: /root
volumeMounts:
- name: shm
mountPath: /dev/shm
securityContext:
capabilities:
add:
- SYS_RESOURCE
- IPC_LOCK
restartPolicy: Never
volumes:
- name: shm
emptyDir:
medium: Memory
sizeLimit: 8GiKey configurations
Configuration item | Description |
| The pod uses the network of the host node and directly accesses the RDMA device. |
| Requests RDMA device resources. |
| Requests GPU resources. Adjust the value as needed. |
| The shared memory volume that multiple processes use to share data. |
| The Linux capabilities that RDMA applications require. |
Scenario 2: Use RDMA in non-hostNetwork mode
In non-hostNetwork mode, each pod has its own IP address. This mode requires the following:
The compute network of the Lingjun bare metal cluster set to IPv6. Select IPv6 mode when you create the cluster. Otherwise, the RDMA configuration does not take effect.
The Enable RDMA network support (non-hostNetwork mode) configuration item of the RDMA device plugin add-on set to
True. For more information, see RDMA overview.
apiVersion: batch/v1
kind: Job
metadata:
name: rdma-non-hostnetwork-test
spec:
parallelism: 1
template:
spec:
hostNetwork: false
tolerations:
- operator: Exists
containers:
- name: rdma-test
image: "<image>"
command:
- sh
- -c
- |
python /workspace/benchmark.py
resources:
limits:
nvidia.com/gpu: 8
rdma/hca: 1
workingDir: /root
volumeMounts:
- name: shm
mountPath: /dev/shm
securityContext:
capabilities:
add:
- SYS_RESOURCE
- IPC_LOCK
restartPolicy: Never
volumes:
- name: shm
emptyDir:
medium: Memory
sizeLimit: 8GiCompared with Scenario 1, only hostNetwork: false and the Job name (rdma-non-hostnetwork-test) differ. For the meanings of the other configuration items, see the key configurations in Scenario 1.
After you submit the Job, view the pod logs to check the RDMA test results. Replace <image> with an image that provides your test script at /workspace/benchmark.py.
Switch modes
To switch between shared mode and exclusive mode, update the configuration on the node pool. Runtime switchover is not supported.
Before you switch the mode, make sure that no pod on the node is using rdma/hca resources. Otherwise, the device allocations of existing pods are revoked.
To let a pod exclusively use a physical RDMA NIC with NUMA affinity, switch to exclusive mode. For more information, see Use RDMA exclusive mode.