refactor: offload DP/DRA management to KMM#59
Conversation
|
Hi @abyrne55 ! Thanks for the PoC!
I'm still thinking if I'd like to have DP/DRA deployment also in the base-operator side. For anyone not wanting to deploy KMM to their cluster. Both methods could use the same building blocks so there wouldn't be too much overhead. More testing though. |
Replace direct DevicePlugin and DRA DaemonSet management with a single KMM (Kernel Module Management) Module CR. Two controllers collapse into one, and the operator no longer needs to build DaemonSets, manage RBAC, handle pod readiness, or construct OpenShift SCCs at runtime. RBAC, SCC, ValidatingAdmissionPolicy, and DeviceClass resources have been moved from operator-managed code into Helm templates and kustomize overlays. A new optional kernelModule CRD field enables OOT driver loading via KMM when set. Signed-off-by: Anthony Byrne <abyrne@redhat.com>
|
@tkatila thanks for taking a look! My latest push should resolve the Re. the KMM version, I've been using "bleeding edge" builds from On the K8s object creation move: the main motivation was reducing the operator's RBAC footprint. Agreed it's a tradeoff: happy to discuss where to draw the line. Re. keeping a non-KMM path: let's discuss. I think that might negate a lot of the maintainability benefits of this PR. |
This PR replaces the operator's direct DP/DRA DaemonSet management with a single KMM (Kernel Module Management)
ModuleCR. Two controllers collapse into one, and the operator no longer needs to build DaemonSets, manage RBAC, handle pod readiness, or construct OpenShift SCCs at runtime.DevicePluginReconciler,DRAReconciler)KMMReconciler)Existing ClusterPolicy specs work unchanged — KMM is used transparently under the hood.
Beyond simplifying what we already have, KMM also brings capabilities we'd otherwise need to build: OOT kernel module loading (see new CRD field below), kernel-version-aware rollouts, ordered upgrades, pre-flight validation, and build/sign integration. Ordered upgrades and pre-flight validation apply immediately for OOT driver modules; build/sign integration is available when needed.
How it works
A new
KMMReconcilersub-controller replacesDevicePluginReconcilerandDRAReconcilerin the reconcile loop. It usescontrollerutil.CreateOrPatchto manage the Module CR idempotently, withSetControllerReferenceso the Module is garbage-collected when the ClusterPolicy is deleted.DRA RBAC (ServiceAccount, ClusterRole, ClusterRoleBinding), OpenShift SCCs, and ValidatingAdmissionPolicy resources have been moved out of operator-managed code and into deployment tooling (Helm templates and kustomize overlays).
KMM availability is detected at startup via API group discovery (
kmm.sigs.x-k8s.io), same pattern asDRAEnable. If the CRD isn't installed, the operator starts normally and reports an error in ClusterPolicy status.New CRD field:
kernelModuleWhen
kernelModuleis set, KMM loads the specified OOT driver module on each node. When omitted, the in-tree kernel driver is used.Multi-kernel support
kernelMappingsmaps kernel version patterns to container images, enabling multi-kernel clusters:When
kernelMappingsis empty, a single wildcard mapping (^.+$) is generated fromimage. WhenkernelMappingsis set,imageserves as a KMM-level fallback for mappings that omitcontainerImage.In-cluster builds
Each kernel mapping can include a
buildspec for cluster-time driver image building via KMM:Additional fields
inTreeModulesToRemovemoduleNamealways included implicitly.modulesLoadingOrdermoduleName, >=2 entries).firmwarePathModprobeSpec.FirmwarePath).skipTLSVerifyRegistryTLS).KMM status
ClusterPolicyStatus.kmmStatusreports module loader availability (available/desired), visible viakubectl get clusterpolicyas a newKMMcolumn. ShowsN/AwhenkernelModuleis nil (in-tree mode).Mapping to KMM Module CR
ModuleNameModprobeSpec.ModuleNameImageModuleLoaderContainerSpec.ContainerImage(fallback)KernelMappings[]ModuleLoaderContainerSpec.KernelMappings[]InTreeModulesToRemoveModuleLoaderContainerSpec.InTreeModulesToRemoveModulesLoadingOrderModprobeSpec.ModulesLoadingOrderFirmwarePathModprobeSpec.FirmwarePathSkipTLSVerifyRegistryTLS.InsecureSkipTLSVerifyAligned with tkatila's
DriverXeSpecAPI sketch. Genericized Xe-specific fields (e.g.,XeTag/XeSHA→BuildArgs). Skipped fields already covered elsewhere (NodeSelector,PullSecret,Enable) and Xe-specific enums (XeOSTarget). NoSignspec yet.Known limitations
Test results
Tested on OCP 4.22.2 (SNO) with two Intel Arc Pro B70 GPUs. KMM and NFD pre-installed.
/dev/dridevices/dev/dridevicesmoduleName+image): KMM loaded OOT xe module, DRA ResourceSlices populated, test pod saw GPUsmake testpasses (all specs including expanded KMM controller tests)This PR was written in part with the assistance of generative AI.