@@ -33,6 +33,7 @@ import (
3333 apierrors "k8s.io/apimachinery/pkg/api/errors"
3434 metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
3535 "k8s.io/apimachinery/pkg/runtime"
36+ "k8s.io/utils/ptr"
3637 ctrl "sigs.k8s.io/controller-runtime"
3738 "sigs.k8s.io/controller-runtime/pkg/builder"
3839 "sigs.k8s.io/controller-runtime/pkg/client"
@@ -49,6 +50,10 @@ const (
4950 kubeletPluginsPath = "/var/lib/kubelet/plugins/"
5051 kubeletPluginsRegistryVolumeName = "kubelet-plugins-registry"
5152 kubeletPluginsRegistryPath = "/var/lib/kubelet/plugins_registry/"
53+ cdiVolumeName = "cdi"
54+ cdiPath = "/var/run/cdi"
55+
56+ draHealthcheckPort = 51515
5257)
5358
5459type DRAReconciler struct {
@@ -465,9 +470,64 @@ func (dsci *draDaemonSetCreatorImpl) setDRAAsDesired(
465470 },
466471 }
467472
473+ cdiVolume := v1.Volume {
474+ Name : cdiVolumeName ,
475+ VolumeSource : v1.VolumeSource {
476+ HostPath : & v1.HostPathVolumeSource {
477+ Path : cdiPath ,
478+ Type : & hostPathDirOrCreate ,
479+ },
480+ },
481+ }
482+
468483 containerVolumeMounts := []v1.VolumeMount {
469484 {Name : kubeletPluginsVolumeName , MountPath : kubeletPluginsPath },
470485 {Name : kubeletPluginsRegistryVolumeName , MountPath : kubeletPluginsRegistryPath },
486+ {Name : cdiVolumeName , MountPath : cdiPath },
487+ }
488+
489+ presetEnv := []v1.EnvVar {
490+ {
491+ Name : "NODE_NAME" ,
492+ ValueFrom : & v1.EnvVarSource {
493+ FieldRef : & v1.ObjectFieldSelector {FieldPath : "spec.nodeName" },
494+ },
495+ },
496+ {
497+ Name : "POD_UID" ,
498+ ValueFrom : & v1.EnvVarSource {
499+ FieldRef : & v1.ObjectFieldSelector {FieldPath : "metadata.uid" },
500+ },
501+ },
502+ {
503+ Name : "CDI_ROOT" ,
504+ Value : cdiPath ,
505+ },
506+ {
507+ Name : "KUBELET_REGISTRAR_DIRECTORY_PATH" ,
508+ Value : kubeletPluginsRegistryPath ,
509+ },
510+ {
511+ Name : "KUBELET_PLUGINS_DIRECTORY_PATH" ,
512+ Value : kubeletPluginsPath ,
513+ },
514+ {
515+ Name : "HEALTHCHECK_PORT" ,
516+ Value : fmt .Sprintf ("%d" , draHealthcheckPort ),
517+ },
518+ }
519+
520+ draLivenessProbe := & v1.Probe {
521+ ProbeHandler : v1.ProbeHandler {
522+ GRPC : & v1.GRPCAction {
523+ Port : draHealthcheckPort ,
524+ Service : ptr .To ("liveness" ),
525+ },
526+ },
527+ InitialDelaySeconds : 30 ,
528+ PeriodSeconds : 10 ,
529+ TimeoutSeconds : 5 ,
530+ FailureThreshold : 3 ,
471531 }
472532
473533 standardLabels := map [string ]string {
@@ -505,13 +565,14 @@ func (dsci *draDaemonSetCreatorImpl) setDRAAsDesired(
505565 Finalizers : []string {constants .NodeLabelerFinalizer },
506566 },
507567 Spec : v1.PodSpec {
508- InitContainers : generatePodContainerSpec (mod .Spec .DRA .InitContainer , "dra-init" , nil ),
509- Containers : generatePodContainerSpec (& mod .Spec .DRA .Container , "dra" , containerVolumeMounts ),
568+ InitContainers : generatePodContainerSpec (mod .Spec .DRA .InitContainer , "dra-init" , nil , nil , nil ),
569+ Containers : generatePodContainerSpec (& mod .Spec .DRA .Container , "dra" , containerVolumeMounts , presetEnv , draLivenessProbe ),
510570 PriorityClassName : "system-node-critical" ,
571+ HostNetwork : true ,
511572 ImagePullSecrets : getPodPullSecrets (mod .Spec .ImageRepoSecret ),
512573 NodeSelector : nodeSelector ,
513574 ServiceAccountName : mod .Spec .DRA .ServiceAccountName ,
514- Volumes : append ([]v1.Volume {pluginsVolume , registryVolume }, mod .Spec .DRA .Volumes ... ),
575+ Volumes : append ([]v1.Volume {pluginsVolume , registryVolume , cdiVolume }, mod .Spec .DRA .Volumes ... ),
515576 Tolerations : mod .Spec .Tolerations ,
516577 AutomountServiceAccountToken : mod .Spec .DRA .AutomountServiceAccountToken ,
517578 },
0 commit comments