feat: add an opt-in ResourceClaim analyzer for missing DeviceClass references
Is your feature request related to a problem?
Kubernetes Dynamic Resource Allocation (DRA) uses ResourceClaim objects to request devices. Each device request references a cluster-scoped DeviceClass by name. k8sgpt currently has no analyzer for these resources, so a claim that points to a deleted or never-created DeviceClass is not reported by the cluster analysis.
This can leave a workload unable to obtain its requested device while the cause is only visible by manually comparing the claim with the cluster's DeviceClass objects.
Kubernetes v1.32 documents DRA as a beta feature that is disabled by default, so this should be an optional analyzer and must not change the default analyzer set.
Describe the solution you'd like
Add an optional ResourceClaim analyzer for the resource.k8s.io/v1beta1 API:
- List cluster-scoped
DeviceClassobjects and build the set of available class names. - List
ResourceClaimobjects through the existing Kubernetes client. - Report each claim that has a
spec.devices.requests[].deviceClassNamereference which does not resolve to an existingDeviceClass. - Register the analyzer as an additional filter named
ResourceClaimand document it in the analyzer list. - Preserve the existing namespace and label-selector behavior for the claims being analyzed. The label selector must not be applied to the reference lookup, because hiding a
DeviceClassthrough a label selector would create a false missing-reference finding.
The regression coverage should include:
- a claim with one valid and one missing
DeviceClassreference; - duplicate requests for the same missing class being reported once per claim;
- a claim with no device requests producing no finding;
- label selection applying to claims without hiding referenced
DeviceClassobjects.
Out of scope
- reporting an unallocated claim as an error, because allocation can legitimately be pending;
- validating driver-specific selectors or device capacity;
- analyzing
ResourceClaimTemplate,ResourceSlice, or Pod-to-claim wiring; - changing the default analyzer set or enabling the DRA feature gate.
Additional context
The repository already depends on k8s.io/api and k8s.io/client-go v0.32.3, which provide the typed resource.k8s.io/v1beta1 API and fake-client support. The implementation can therefore stay within the existing analyzer contract and does not require a dependency upgrade.
I searched the open and closed k8sgpt issues and pull requests for ResourceClaim, ResourceSlice, DeviceClass, and Dynamic Resource Allocation and did not find an overlapping analyzer proposal. The change is limited to the analyzer implementation, focused fake-client tests, analyzer registration, and README documentation.
Would you be willing to help implement this?
Yes. I would be happy to implement this focused scope with fake-client regression tests and documentation after maintainers confirm the analyzer boundary.
Source: k8sgpt-ai/k8sgpt