Skip to content

Commit 302f40e

Browse files
committed
add talos support
Signed-off-by: hydazz <alexanderhyde@icloud.com>
1 parent 4a5ca97 commit 302f40e

File tree

7 files changed

+35
-5
lines changed

7 files changed

+35
-5
lines changed

cmd/compute-domain-kubelet-plugin/cdi.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,14 @@ const (
4646
defaultCDIRoot = "/var/run/cdi"
4747
)
4848

49+
func getTalosLibrarySearchPaths() []string {
50+
return []string{
51+
"/driver-root/usr/local/glibc/usr/lib",
52+
"/driver-root/usr/local/glibc/lib",
53+
"/driver-root/usr/local/glibc/lib64",
54+
}
55+
}
56+
4957
type CDIHandler struct {
5058
logger *logrus.Logger
5159
nvml nvml.Interface
@@ -103,6 +111,7 @@ func NewCDIHandler(opts ...cdiOption) (*CDIHandler, error) {
103111
nvcdi.WithVendor(h.vendor),
104112
nvcdi.WithClass(h.deviceClass),
105113
nvcdi.WithNVIDIACDIHookPath(h.nvidiaCDIHookPath),
114+
nvcdi.WithLibrarySearchPaths(getTalosLibrarySearchPaths()),
106115
)
107116
if err != nil {
108117
return nil, fmt.Errorf("unable to create CDI library for devices: %w", err)
@@ -120,6 +129,7 @@ func NewCDIHandler(opts ...cdiOption) (*CDIHandler, error) {
120129
nvcdi.WithVendor(h.vendor),
121130
nvcdi.WithClass(h.claimClass),
122131
nvcdi.WithNVIDIACDIHookPath(h.nvidiaCDIHookPath),
132+
nvcdi.WithLibrarySearchPaths(getTalosLibrarySearchPaths()),
123133
)
124134
if err != nil {
125135
return nil, fmt.Errorf("unable to create CDI library for claims: %w", err)

cmd/compute-domain-kubelet-plugin/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (r root) getDriverLibraryPath() (string, error) {
3434
"/lib64",
3535
"/lib/x86_64-linux-gnu",
3636
"/lib/aarch64-linux-gnu",
37+
"/usr/local/glibc/usr/lib",
3738
}
3839

3940
libraryPath, err := r.findFile("libnvidia-ml.so.1", librarySearchPaths...)
@@ -52,6 +53,7 @@ func (r root) getNvidiaSMIPath() (string, error) {
5253
"/usr/sbin",
5354
"/bin",
5455
"/sbin",
56+
"/usr/local/bin",
5557
}
5658

5759
binaryPath, err := r.findFile("nvidia-smi", binarySearchPaths...)

cmd/gpu-kubelet-plugin/cdi.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,14 @@ const (
5151
procNvCapsPath = "/proc/driver/nvidia/capabilities"
5252
)
5353

54+
func getTalosLibrarySearchPaths() []string {
55+
return []string{
56+
"/driver-root/usr/local/glibc/usr/lib",
57+
"/driver-root/usr/local/glibc/lib",
58+
"/driver-root/usr/local/glibc/lib64",
59+
}
60+
}
61+
5462
type CDIHandler struct {
5563
logger *logrus.Logger
5664
nvml nvml.Interface
@@ -108,6 +116,7 @@ func NewCDIHandler(opts ...cdiOption) (*CDIHandler, error) {
108116
nvcdi.WithVendor(h.vendor),
109117
nvcdi.WithClass(h.deviceClass),
110118
nvcdi.WithNVIDIACDIHookPath(h.nvidiaCDIHookPath),
119+
nvcdi.WithLibrarySearchPaths(getTalosLibrarySearchPaths()),
111120
)
112121
if err != nil {
113122
return nil, fmt.Errorf("unable to create CDI library for devices: %w", err)
@@ -125,6 +134,7 @@ func NewCDIHandler(opts ...cdiOption) (*CDIHandler, error) {
125134
nvcdi.WithVendor(h.vendor),
126135
nvcdi.WithClass(h.claimClass),
127136
nvcdi.WithNVIDIACDIHookPath(h.nvidiaCDIHookPath),
137+
nvcdi.WithLibrarySearchPaths(getTalosLibrarySearchPaths()),
128138
)
129139
if err != nil {
130140
return nil, fmt.Errorf("unable to create CDI library for claims: %w", err)

cmd/gpu-kubelet-plugin/root.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ func (r root) getDriverLibraryPath() (string, error) {
3434
"/lib64",
3535
"/lib/x86_64-linux-gnu",
3636
"/lib/aarch64-linux-gnu",
37+
"/usr/local/glibc/usr/lib",
3738
}
3839

3940
libraryPath, err := r.findFile("libnvidia-ml.so.1", librarySearchPaths...)
@@ -52,6 +53,7 @@ func (r root) getNvidiaSMIPath() (string, error) {
5253
"/usr/sbin",
5354
"/bin",
5455
"/sbin",
56+
"/usr/local/bin",
5557
}
5658

5759
binaryPath, err := r.findFile("nvidia-smi", binarySearchPaths...)

deployments/helm/nvidia-dra-driver-gpu/templates/kubeletplugin.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ spec:
137137
- name: NVIDIA_VISIBLE_DEVICES
138138
value: void
139139
- name: CDI_ROOT
140-
value: /var/run/cdi
140+
value: {{ .Values.cdiRoot | quote }}
141141
- name: NVIDIA_MIG_CONFIG_DEVICES
142142
value: all
143143
- name: NODE_NAME
@@ -174,7 +174,7 @@ spec:
174174
mountPath: {{ .Values.kubeletPlugin.kubeletPluginsDirectoryPath | quote }}
175175
mountPropagation: Bidirectional
176176
- name: cdi
177-
mountPath: /var/run/cdi
177+
mountPath: {{ .Values.cdiRoot | quote }}
178178
- name: driver-root
179179
mountPath: /driver-root
180180
readOnly: true
@@ -238,7 +238,7 @@ spec:
238238
- name: NVIDIA_VISIBLE_DEVICES
239239
value: void
240240
- name: CDI_ROOT
241-
value: /var/run/cdi
241+
value: {{ .Values.cdiRoot | quote }}
242242
- name: NVIDIA_MIG_CONFIG_DEVICES
243243
value: all
244244
- name: NODE_NAME
@@ -277,7 +277,7 @@ spec:
277277
mountPath: {{ .Values.kubeletPlugin.kubeletPluginsDirectoryPath | quote }}
278278
mountPropagation: Bidirectional
279279
- name: cdi
280-
mountPath: /var/run/cdi
280+
mountPath: {{ .Values.cdiRoot | quote }}
281281
- name: driver-root
282282
mountPath: /driver-root
283283
mountPropagation: HostToContainer
@@ -303,7 +303,7 @@ spec:
303303
path: {{ .Values.kubeletPlugin.kubeletPluginsDirectoryPath | quote }}
304304
- name: cdi
305305
hostPath:
306-
path: /var/run/cdi
306+
path: {{ .Values.cdiRoot | quote }}
307307
- name: driver-root-parent
308308
hostPath:
309309
# If nvidiaDriverRoot == "/" then its parent is itself. Otherwise, get

deployments/helm/nvidia-dra-driver-gpu/values.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,10 @@ nvidiaDriverRoot: /
2626
# If not specified, the default path inferred from the nvidia-container-toolkit library version will be used.
2727
nvidiaCDIHookPath: ""
2828

29+
# CDI root directory path.
30+
# This is where CDI spec files are stored and accessed by the runtime.
31+
cdiRoot: "/var/run/cdi"
32+
2933
nameOverride: ""
3034
fullnameOverride: ""
3135
namespaceOverride: ""

hack/kubelet-plugin-prestart.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ validate_and_exit_on_success () {
4747
/driver-root/usr/bin \
4848
/driver-root/usr/sbin \
4949
/driver-root/bin \
50+
/driver-root/usr/local/bin \
5051
/driver-root/sbin \
5152
-maxdepth 1 -type f -name "nvidia-smi" 2> /dev/null | head -n1
5253
)
@@ -60,6 +61,7 @@ validate_and_exit_on_success () {
6061
/driver-root/usr/lib64 \
6162
/driver-root/usr/lib/x86_64-linux-gnu \
6263
/driver-root/usr/lib/aarch64-linux-gnu \
64+
/driver-root/usr/local/glibc/usr/lib \
6365
/driver-root/lib64 \
6466
/driver-root/lib/x86_64-linux-gnu \
6567
/driver-root/lib/aarch64-linux-gnu \

0 commit comments

Comments
 (0)