Skip to content

Commit 071452d

Browse files
committed
nvidia-container-toolkit: support both cdi and legacy stacks
Update the NVIDIA Container Toolkit configuration template to dynamically select the mode based off the configurations used in the Kubernetes Device Plugin. Signed-off-by: Jingwei Wang <[email protected]>
1 parent 3f0cbac commit 071452d

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

packages/nvidia-container-toolkit/nvidia-container-toolkit-config-k8s

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[required-extensions]
22
nvidia-container-runtime = "v1"
3-
std = { version = "v1", helpers = ["default"] }
3+
std = { version = "v1", helpers = ["default", "is_array", "is_string"] }
44

55
+++
66
### generated from the template file ###
@@ -12,3 +12,22 @@ root = "/"
1212
path = "/usr/bin/nvidia-container-cli"
1313
environment = []
1414
ldconfig = "@/sbin/ldconfig"
15+
16+
[nvidia-container-runtime]
17+
{{#if settings.kubelet-device-plugins.nvidia.device-list-strategy}}
18+
{{#if (is_array settings.kubelet-device-plugins.nvidia.device-list-strategy) }} {{! Begin is array}}
19+
{{#if (eq settings.kubelet-device-plugins.nvidia.device-list-strategy.[0] "cdi-cri") }}
20+
mode="cdi"
21+
{{else}}
22+
mode="legacy"
23+
{{/if}} {{! End is array}}
24+
{{else if (is_string settings.kubelet-device-plugins.nvidia.device-list-strategy) }} {{! Begin is string}}
25+
{{#if (eq settings.kubelet-device-plugins.nvidia.device-list-strategy "cdi-cri") }}
26+
mode="cdi"
27+
{{else}}
28+
mode="legacy"
29+
{{/if}}
30+
{{/if}} {{! End is string}}
31+
{{else}}
32+
mode="legacy"
33+
{{/if}}

0 commit comments

Comments
 (0)