@@ -1379,11 +1379,50 @@ func TransformToolkit(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec, n
13791379func transformForRuntime (obj * appsv1.DaemonSet , config * gpuv1.ClusterPolicySpec , runtime string , container * corev1.Container ) error {
13801380 setContainerEnv (container , "RUNTIME" , runtime )
13811381
1382- if runtime == gpuv1 .Containerd .String () {
1383- // Set the runtime class name that is to be configured for containerd
1384- setContainerEnv (container , "CONTAINERD_RUNTIME_CLASS" , getRuntimeClassName (config ))
1382+ // In NRI plugin mode the toolkit installer runs the noop runtime configurer
1383+ // (see nvidia-ctk-installer's NewConfigurer): it does not read or modify the
1384+ // container runtime configuration and does not restart the runtime. Mounting the
1385+ // runtime config files and socket is therefore unnecessary in this mode, and the
1386+ // hostPath mounts (e.g. /etc/containerd/conf.d with DirectoryOrCreate) break on
1387+ // read-only hosts such as Talos. Only the NRI socket mount (below) is required.
1388+ if config .CDI .IsNRIPluginEnabled () {
1389+ transformNRISocketMounts (obj , container )
1390+ } else {
1391+ if runtime == gpuv1 .Containerd .String () {
1392+ // Set the runtime class name that is to be configured for containerd
1393+ setContainerEnv (container , "CONTAINERD_RUNTIME_CLASS" , getRuntimeClassName (config ))
1394+ }
1395+
1396+ if err := transformRuntimeConfigAndSocketMounts (obj , runtime , container ); err != nil {
1397+ return err
1398+ }
13851399 }
13861400
1401+ return nil
1402+ }
1403+
1404+ // transformNRISocketMounts adds the required NRI socket environment variable and
1405+ // sets up the NRI socket mount
1406+ func transformNRISocketMounts (obj * appsv1.DaemonSet , container * corev1.Container ) {
1407+ // setup mounts for the runtime NRI socket file
1408+ nriSocketFile := getContainerEnv (container , "NRI_SOCKET" )
1409+ if nriSocketFile == "" {
1410+ nriSocketFile = DefaultRuntimeNRISocketFile
1411+ }
1412+ setContainerEnv (container , "NRI_SOCKET" , path .Join (DefaultRuntimeNRISocketTargetDir , path .Base (nriSocketFile )))
1413+
1414+ nriVolMountSocketName := "nri-socket"
1415+ nriVolMountSocket := corev1.VolumeMount {Name : nriVolMountSocketName , MountPath : DefaultRuntimeNRISocketTargetDir }
1416+ container .VolumeMounts = append (container .VolumeMounts , nriVolMountSocket )
1417+
1418+ nriSocketVol := corev1.Volume {Name : nriVolMountSocketName , VolumeSource : corev1.VolumeSource {HostPath : & corev1.HostPathVolumeSource {Path : path .Dir (nriSocketFile ), Type : ptr .To (corev1 .HostPathDirectoryOrCreate )}}}
1419+ obj .Spec .Template .Spec .Volumes = append (obj .Spec .Template .Spec .Volumes , nriSocketVol )
1420+ }
1421+
1422+ // transformRuntimeConfigAndSocketMounts configures the toolkit container with the
1423+ // mounts and environment required for the toolkit installer to update the container
1424+ // runtime configuration (top-level config, drop-in config, and runtime socket).
1425+ func transformRuntimeConfigAndSocketMounts (obj * appsv1.DaemonSet , runtime string , container * corev1.Container ) error {
13871426 // For runtime config files we have top-level configs and drop-in files.
13881427 // These are supported as follows:
13891428 // * Docker only supports top-level config files.
@@ -1489,22 +1528,6 @@ func transformForRuntime(obj *appsv1.DaemonSet, config *gpuv1.ClusterPolicySpec,
14891528 obj .Spec .Template .Spec .Volumes = append (obj .Spec .Template .Spec .Volumes , socketVol )
14901529 }
14911530
1492- if config .CDI .IsNRIPluginEnabled () {
1493- // setup mounts for the runtime NRI socket file
1494- nriSocketFile := getContainerEnv (container , "NRI_SOCKET" )
1495- if nriSocketFile == "" {
1496- nriSocketFile = DefaultRuntimeNRISocketFile
1497- }
1498- setContainerEnv (container , "NRI_SOCKET" , DefaultRuntimeNRISocketTargetDir + path .Base (nriSocketFile ))
1499-
1500- nriVolMountSocketName := "nri-socket"
1501- nriVolMountSocket := corev1.VolumeMount {Name : nriVolMountSocketName , MountPath : DefaultRuntimeNRISocketTargetDir }
1502- container .VolumeMounts = append (container .VolumeMounts , nriVolMountSocket )
1503-
1504- nriSocketVol := corev1.Volume {Name : nriVolMountSocketName , VolumeSource : corev1.VolumeSource {HostPath : & corev1.HostPathVolumeSource {Path : path .Dir (nriSocketFile ), Type : ptr .To (corev1 .HostPathDirectoryOrCreate )}}}
1505- obj .Spec .Template .Spec .Volumes = append (obj .Spec .Template .Spec .Volumes , nriSocketVol )
1506- }
1507-
15081531 return nil
15091532}
15101533
0 commit comments