Skip to content

[orchestrator] Grant networkpolicies to the orchestrator-explorer ClusterRole - #3382

Merged
tbavelier merged 2 commits into
mainfrom
kangyi/rbac-networkpolicies
Aug 21, 2026
Merged

[orchestrator] Grant networkpolicies to the orchestrator-explorer ClusterRole#3382
tbavelier merged 2 commits into
mainfrom
kangyi/rbac-networkpolicies

Conversation

@kangyili

@kangyili kangyili commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

What

Add networkpolicies to the networking.k8s.io rule in the orchestrator-explorer feature's ClusterRole (used by the cluster-checks runner / cluster-agent when it runs the orchestrator check).

Why — this is a bug

The orchestrator check already lists networkpolicies as a collected resource, but the operator-generated ClusterRole only grants ingresses under networking.k8s.io.

The public Datadog Helm chart already grants this exact permission to the cluster-agent for orchestrator-explorer, confirming this is a gap on the operator side:

https://github.com/DataDog/helm-charts/blob/main/charts/datadog/templates/cluster-agent-rbac.yaml#L239-L243

- apiGroups:
  - networking.k8s.io
  resources:
  - networkpolicies
  verbs:
  - list

Change

One line in internal/controller/datadogagent/feature/orchestratorexplorer/rbac.go:

- Resources: []string{rbac.IngressesResource},
+ Resources: []string{rbac.IngressesResource, rbac.NetworkPolicyResource},

Test plan

  • go build ./... — passes
  • go test ./internal/controller/datadogagent/feature/orchestratorexplorer/... — passes
  • go test ./internal/controller/datadogagent/... — passes (all features + controller + override + store + global + merger + object)
  • Post-merge, in an operator-managed cluster, confirm the generated *-orch-exp-ccr ClusterRole includes networkpolicies and that the orchestrator check (DCA or CCR) no longer logs the RBAC-denied error.

🤖 Generated with Claude Code

The orchestrator explorer's `other` collector lists `networkpolicies`, but
the operator-generated ClusterRole for the cluster-checks runner only grants
`ingresses` under `networking.k8s.io`. When the check runs on the CCR the
missing permission fails silently; when it runs on the cluster-agent leader
(the default customer setup) it surfaces as a visible RBAC-denied error:

  Failed to watch networkpolicies.networking.k8s.io: forbidden ... cannot
  watch resource "networkpolicies" ... at the cluster scope

The public Datadog Helm chart already grants this exact permission to the
cluster-agent for orchestrator-explorer:
https://github.com/DataDog/helm-charts/blob/main/charts/datadog/templates/cluster-agent-rbac.yaml#L239-L243

Add `networkpolicies` alongside `ingresses` in the networking.k8s.io rule so
operator-managed setups match the Helm chart and can collect NetworkPolicy
manifests through the orchestrator check regardless of where it runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@kangyili
kangyili requested a review from a team August 21, 2026 11:30
@kangyili
kangyili requested a review from a team as a code owner August 21, 2026 11:30
@kangyili kangyili added the bug Something isn't working label Aug 21, 2026
@kangyili kangyili added this to the v1.31.0 milestone Aug 21, 2026
@kangyili kangyili changed the title [orchestrator] Grant networkpolicies to the CCR ClusterRole [orchestrator] Grant networkpolicies to the orchestrator-explorer ClusterRole Aug 21, 2026
@datadog-prod-us1-4

datadog-prod-us1-4 Bot commented Aug 21, 2026

Copy link
Copy Markdown

Pipelines  Code Coverage

🎯 Code Coverage (details)
Patch Coverage: 100.00%
Overall Coverage: 50.12% (+0.00%)

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: c33b36c | Docs | View more details | Give us feedback!

`make golden-update` — picks up `networkpolicies` on the operator-generated
orchestrator-explorer ClusterRole across all 10 render scenarios.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
gh-worker-dd-mergequeue-cf854d Bot pushed a commit that referenced this pull request Aug 21, 2026
…sterRole (#3382) (#3383)

[orchestrator] Grant networkpolicies to the orchestrator-explorer  ClusterRole (#3382)

* [orchestrator] Grant networkpolicies to the CCR ClusterRole

The orchestrator explorer's `other` collector lists `networkpolicies`, but
the operator-generated ClusterRole for the cluster-checks runner only grants
`ingresses` under `networking.k8s.io`. When the check runs on the CCR the
missing permission fails silently; when it runs on the cluster-agent leader
(the default customer setup) it surfaces as a visible RBAC-denied error:

  Failed to watch networkpolicies.networking.k8s.io: forbidden ... cannot
  watch resource "networkpolicies" ... at the cluster scope

The public Datadog Helm chart already grants this exact permission to the
cluster-agent for orchestrator-explorer:
https://github.com/DataDog/helm-charts/blob/main/charts/datadog/templates/cluster-agent-rbac.yaml#L239-L243

Add `networkpolicies` alongside `ingresses` in the networking.k8s.io rule so
operator-managed setups match the Helm chart and can collect NetworkPolicy
manifests through the orchestrator check regardless of where it runs.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* Regenerate golden renderer fixtures after adding networkpolicies

`make golden-update` — picks up `networkpolicies` on the operator-generated
orchestrator-explorer ClusterRole across all 10 render scenarios.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
(cherry picked from commit 007a456)

Co-authored-by: kangyili <kangyi.li@datadoghq.com>
Co-authored-by: timothee.bavelier <timothee.bavelier@datadoghq.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants