Repository navigation
feat(ksm): grant DRA RBAC for Cluster Agent 7.85.0+; mount CDI dir for GPU monitoring - #3703
Conversation
|
🎯 Code Coverage (details) 🔗 Commit SHA: ae6206c | Docs | View more details | Give us feedback! |
There was a problem hiding this comment.
🟡 Changes recommended
The version check uses incorrect image override precedence, which can omit required DRA permissions for the image actually running and cause collectors to fail with Forbidden errors.
2 open issues
What changed in this PR
Adds support for Kubernetes Dynamic Resource Allocation (DRA) monitoring through version-gated KSM permissions and access to host CDI specifications for GPU attribution.
Changes:
- Grants DRA read permissions when the component running KSM is version 7.85.0 or later.
- Mounts the CDI directory read-only for GPU monitoring, excluding GKE Autopilot.
- Adds tests, documentation, and an example for enabling DRA collectors.
| File | Description |
|---|---|
pkg/kubernetes/rbac/const.go |
Defines DRA API group and resource constants. |
internal/controller/testutils/renderer/testdata/golden/suppression-baseline.golden.yaml |
Updates expected output with the CDI mount. |
internal/controller/datadogagent/feature/kubernetesstatecore/rbac.go |
Adds conditional DRA permissions. |
internal/controller/datadogagent/feature/kubernetesstatecore/rbac_test.go |
Tests DRA permission generation. |
internal/controller/datadogagent/feature/kubernetesstatecore/feature.go |
Gates DRA RBAC on the executing component's version. |
internal/controller/datadogagent/feature/kubernetesstatecore/feature_test.go |
Tests version gating for Cluster Agent and runners. |
internal/controller/datadogagent/feature/kubernetesstatecore/const.go |
Defines the minimum DRA collector version. |
internal/controller/datadogagent/feature/gpu/feature.go |
Adds the CDI mount and Autopilot exclusion. |
internal/controller/datadogagent/feature/gpu/feature_test.go |
Tests CDI volumes and provider-specific removal. |
internal/controller/datadogagent/feature/gpu/const.go |
Defines CDI volume paths. |
internal/controller/datadogagent_controller.go |
Declares operator DRA permissions for generation. |
examples/datadogagent/datadog-agent-with-dra.yaml |
Provides a DRA and GPU monitoring example. |
docs/kubernetes_state_metrics.md |
Documents DRA collectors and version requirements. |
config/rbac/role.yaml |
Grants the operator DRA list/watch permissions. |
Review effort: Balanced
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 6299e5873a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
…aintRule requirement
Main now defaults to Agent 7.85.0 (#3708), so the DRA RBAC gated on >= 7.85.0 renders in the comprehensive fixtures. Regenerated with go test ./internal/controller/testutils/renderer/... -update.
6299e58 to
1b99adc
Compare
There was a problem hiding this comment.
🟡 Changes recommended
Image overrides that only set pull policy or secrets incorrectly produce an empty component version, withholding DRA permissions from supported Cluster Agents or runners and causing configured collectors to receive Forbidden errors.
1 open issue
2 resolved since last review
Review effort: Balanced
…the DRA gate An image override that sets no tag (only pullPolicy or pullSecrets, or a name without a tag) keeps the bundled image tag when rendered, but GetComponentVersion returned "" or "latest" for it, so the fail-closed DRA gate withheld the RBAC from a supported Cluster Agent or Cluster Checks Runner. Resolve the component's bundled version for those overrides; explicit unparseable tags still fail closed.
bcb5057
into
main


What does this PR do?
kubernetes_state_core(Cluster Agent, or Cluster Checks Runner when KSM runs there) is 7.85.0+, adds aresource.k8s.iolist/watchrule forresourceclaims,resourceslicesanddevicetaintrulesto the KSM ClusterRole. The operator's own ClusterRole gets the same permissions so it can grant them./var/run/cdiread-only at/host/var/run/cdiin the core agent container. The mount is removed on GKE Autopilot.docs/kubernetes_state_metrics.mdhow to enable DRA collection throughconf.configData.Motivation
Cluster Agent 7.85.0 collects Kubernetes DRA metrics when users add the
resourceclaims,resourceslicesanddevicetaintrulescollectors to a custom KSM config. Users can add the collectors themselves but can't grant the RBAC. The CDI specs let the node agent attribute GPUs to pods that got them through DRA.Example
examples/datadogagent/datadog-agent-with-dra.yamlshows a working setup: Cluster Agent and Agent image overrides to7.85.0,features.gpu.enabled: true, andkubeStateMetricsCore.conf.configDatawith the full default collector list plusresourceclaims,resourceslices,devicetaintrules(and an optionaldra_device_classesfilter).Additional Notes
:devget no rule): a Cluster Agent older than 7.85 fails the wholekubernetes_state_corecheck on DRA clusters when given these collector names.Minimum Agent Versions
Describe your test plan
Unit tests cover the RBAC version check (Cluster Agent and Cluster Checks Runner, rc and
:devtags, no override, custom conf) and the CDI mount including the Autopilot removal.make gotest,make golden-testandmake lintpass;make generate && make manifestsleaves no diff.To check on a cluster: set the Cluster Agent image to 7.85.0+, add the three collectors through
features.kubeStateMetricsCore.conf.configData, and confirmkubernetes_state.resourceslice.devicesreports with no Forbidden errors in the Cluster Agent logs.Checklist
bug,enhancement,refactoring,documentation,tooling, and/ordependenciesqa/skip-qalabel