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. |
|
@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. |
c5ad481 to
846d083
Compare
Roger. I'll try the latest patch set and KMMO build tomorrow.
Right. I do like the reduced footprint. I'll ask internally if we have any preference on the direction.
Can you help me understand what benefits KMMO's DP/DRA handling has compared to the current state? AFAIK, main benefits from KMMO are related to the KMD handling, and the DP/DRA handling is more like helper functionality. Are kernel-version-aware rollouts, ordered upgrades, or pre-flight validation functionalities tied to DP/DRA being part of the Module CR? I see moving the DP/DRA handling to KMMO as a risk mostly. It introduces unknown delays to our internal timelines if there are issues/missing functionality with KMMO (like your two PRs related to security and probes). And without KMMO, the ClusterPolicy CRD is effectively broken. KMMO dependency can be made more visible via helm chart prehooks, CRD's webhooks, or I think even with operator bundle's dependencies, but I feel KMMO is a dependency for OoT KMD handling, not a core component for the base operator to function. |
|
Thanks for your feedback @tkatila!
The main benefit is less reconciler code to maintain within gpu-base-operator: KMM owns the DP/DRA DaemonSet lifecycle instead of the operator managing it directly. The Module CR also provides a single point of observability for the full driver+DP/DRA stack, though that's an admittedly minor benefit.
For OOT scenarios: partially. KMM's pre-flight validation is only concerned with OOT KMD images, and it doesn't currently care about DP/DRA. Ordered upgrades do include DP/DRA: KMM's version label state machine enforces old DP/DRA drain → old KMD unload → new KMD load → new DP/DRA deploy. And DP/DRA scheduling is gated on the For in-tree scenarios: no, as these KMM features don't engage without an OOT KMD image configured.
These are good points, and your concerns re. timeline coupling are especially valid.
Given this discussion, I think this could be a reasonable design. I'll sketch out a version of this PR that illustrates a KMM-optional path to ensure we're all on the same page. I'll also discuss this approach internally to ensure we're not missing anything. |
DP/DRA should handle KMD coming and going. As they are not accessing the drm devices themselves, they should be fine running through KMD change. But XPUMD is different. That will probably crash when KMD vanishes underneath it. Maybe the
That would be my preference. I think this PR shows that it's possible to move the DP/DRA handling to KMMO also later, if there are more pressing reasons for it. |
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>
|
Closing in favor of #79. We may revisit handing off DRA/DP handling to KMM in the future |
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
privileged: trueon DP and DRA containers. The old DP ran unprivileged with a hardened security context. There is no override via the Module CR — this would require an upstream KMM change (optionalSecurityContextonCommonContainerSpec). Implementing PR Support configurable SecurityContext for DevicePlugin and DRA containers kubernetes-sigs/kernel-module-management#1323 under review.CommonContainerSpechas no probe fields, so this requires an upstream KMM enhancement. Implementing PR Add configurable StartupProbe and LivenessProbe to Module CR kubernetes-sigs/kernel-module-management#1322 under review.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.