[Backport v1.25] [ACTP] Add k8s remediation RBAC rules for private action runner#2780
[Backport v1.25] [ACTP] Add k8s remediation RBAC rules for private action runner#2780dd-octo-sts[bot] wants to merge 1 commit intov1.25from
Conversation
* Add k8s remediation RBAC rules for private action runner When the annotation `cluster-agent.datadoghq.com/private-action-runner-k8s-remediation-enabled` is set to true, extend the cluster agent RBAC with additional policy rules for deployments, pods, configmaps, and events needed for k8s remediation. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * create new clusterrole * update rbac * revert * Add kubebuilder RBAC markers for PAR k8s remediation Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * update comment --------- Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com> (cherry picked from commit 6a0f976)
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: a21e39fe37
ℹ️ About Codex in GitHub
Codex has been enabled to automatically 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 👍.
When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".
| err := managers.RBACManager().AddClusterPolicyRulesByComponent( | ||
| f.owner.GetNamespace(), | ||
| f.getRbacResourcesName(), | ||
| f.clusterServiceAccountName, | ||
| getClusterAgentRBACPolicyRules(f.clusterConfig.IdentitySecretName), | ||
| clusterAgentPolicyRules, |
There was a problem hiding this comment.
Keep self-enroll secret access namespaced
When private_action_runner.self_enroll is true, clusterAgentPolicyRules contains getClusterAgentRBACPolicyRules(...), which used to be installed with AddPolicyRules as a namespaced Role. Binding that same rule here via AddClusterPolicyRulesByComponent makes the Secret permission cluster-wide, so the cluster-agent service account can get/update/create any Secret with the same identity_secret_name in every namespace. In multi-tenant clusters, or when multiple DatadogAgent instances reuse the default secret name, this is a real privilege expansion unrelated to the new remediation access.
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
🤔 This does seem like a valid concern... the DCA now has permissions to update any secret with this name now instead of just the secret within it's own namespace... I think it would be nice to scope this back down to the limited permissions needed. Thoughts?
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## v1.25 #2780 +/- ##
==========================================
- Coverage 38.79% 38.76% -0.03%
==========================================
Files 309 309
Lines 26736 26769 +33
==========================================
+ Hits 10373 10378 +5
- Misses 15584 15611 +27
- Partials 779 780 +1
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report in Codecov by Sentry.
🚀 New features to boost your workflow:
|
Backport 6a0f976 from #2770.
What does this PR do?
Extends the private action runner cluster agent RBAC with additional policy rules when k8s remediation is enabled via the annotation
cluster-agent.datadoghq.com/private-action-runner-k8s-remediation-enabled: "true".When the annotation is set, some
PolicyRuleentries are appended among which:get/watch/patch/createondeployments,pods,configmaps, andeventsupdateonconfigmapsMotivation
K8s remediation actions require the cluster agent to interact with workload resources (deployments, pods) and to record events and manage configmaps. Without these RBAC rules the runner cannot execute remediation workflows.
Why only these permissions?
We conducted an experiment to find the maximum possible capabilities of the DCA SA today (if all features are enabled) and inferred this list for our immediate use cases.
Minimum Agent Versions
No minimum version requirement.
Describe your test plan