Skip to content

Add RBAC for Gateway API, service mesh, and ingress controller CRDs#2874

Open
eliottness wants to merge 4 commits intomainfrom
eliottness/ootb-crd-gateway-mesh-ingress
Open

Add RBAC for Gateway API, service mesh, and ingress controller CRDs#2874
eliottness wants to merge 4 commits intomainfrom
eliottness/ootb-crd-gateway-mesh-ingress

Conversation

@eliottness
Copy link
Copy Markdown
Contributor

@eliottness eliottness commented Apr 7, 2026

What does this PR do?

Adds list/watch RBAC permissions for 14 new API groups to the cluster agent ClusterRole, enabling OOTB collection of network topology CRDs for Cloud Security internet-reachability analysis.

Gated behind features.orchestratorExplorer.networkCRDs.enabled (default: false, opt-in).

New API groups:

  • Gateway API: gateway.networking.k8s.io (resource-specific)
  • Service mesh: networking.istio.io (resource-specific), gateway.envoyproxy.io, traefik.containo.us, policy.linkerd.io, consul.hashicorp.com, mesh.consul.hashicorp.com, kuma.io
  • Ingress controllers: k8s.nginx.org, traefik.io (resource-specific), configuration.konghq.com, core.haproxy.org, ingress.v1.haproxy.org

Motivation

The Datadog Agent is adding OOTB collection of these CRDs for Cloud Security internet-reachability analysis. The operator needs to grant the cluster agent RBAC permissions to list/watch these resources.

RFC: https://datadoghq.atlassian.net/wiki/x/4IOyfAE

Describe how you validated your changes

  • RBAC rules follow the same pattern as existing karpenter/argoproj/fluxcd entries
  • New NetworkCRDsConfig type added to the DatadogAgent v2alpha1 API
  • Shared constants deduplicated with existing appsec RBAC via pkg/kubernetes/rbac/const.go
  • CRD manifests, OpenAPI schemas, deepcopy all regenerated
  • Tests updated

Additional Notes

This PR should be merged before the corresponding agent PR. Collection is opt-in — both the operator flag and the agent-side flags must be enabled.

Related PRs

Repo PR Purpose
DataDog/datadog-agent DataDog/datadog-agent#48966 Agent collection (merge AFTER)
DataDog/dd-go DataDog/dd-go#230589 Backend allowlist (deploy FIRST)
DataDog/helm-charts DataDog/helm-charts#2541 Helm chart RBAC

Add opt-in `networkCRDs.enabled` boolean to OrchestratorExplorerFeatureConfig
that grants list/watch RBAC for 15 API groups used by Gateway API, service
mesh (Istio, Envoy Gateway, Traefik Legacy, Linkerd, Consul, Kuma), and
ingress controllers (NGINX, Traefik, Kong, HAProxy). Uses resource-specific
rules for high-volume vendors (Gateway API, Istio, NGINX, Traefik) and
group-level wildcards for the long tail.

Also replaces inline string literals in appsec RBAC with shared constants.
The gci formatter requires a blank line between the Traefik resources
block and the general resources block, and re-aligns the equals signs
to match the new block's column width.
@codecov-commenter
Copy link
Copy Markdown

codecov-commenter commented Apr 7, 2026

Codecov Report

❌ Patch coverage is 9.19540% with 79 lines in your changes missing coverage. Please review.
✅ Project coverage is 40.03%. Comparing base (3d96136) to head (974bcf2).
⚠️ Report is 15 commits behind head on main.

Files with missing lines Patch % Lines
.../datadogagent/feature/orchestratorexplorer/rbac.go 1.40% 69 Missing and 1 partial ⚠️
...atadogagent/feature/orchestratorexplorer/envvar.go 0.00% 6 Missing and 1 partial ⚠️
...tadogagent/feature/orchestratorexplorer/feature.go 33.33% 1 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #2874      +/-   ##
==========================================
+ Coverage   39.45%   40.03%   +0.58%     
==========================================
  Files         315      319       +4     
  Lines       27482    28640    +1158     
==========================================
+ Hits        10842    11465     +623     
- Misses      15836    16339     +503     
- Partials      804      836      +32     
Flag Coverage Δ
unittests 40.03% <9.19%> (+0.58%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files with missing lines Coverage Δ
...nal/controller/datadogagent/feature/appsec/rbac.go 100.00% <100.00%> (ø)
...tadogagent/feature/orchestratorexplorer/feature.go 70.92% <33.33%> (-1.03%) ⬇️
...atadogagent/feature/orchestratorexplorer/envvar.go 75.00% <0.00%> (-25.00%) ⬇️
.../datadogagent/feature/orchestratorexplorer/rbac.go 62.76% <1.40%> (-37.24%) ⬇️

... and 13 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 3d96136...974bcf2. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@eliottness eliottness added enhancement New feature or request qa/skip-qa labels Apr 7, 2026
gh-worker-dd-mergequeue-cf854d bot pushed a commit to DataDog/datadog-agent that referenced this pull request Apr 9, 2026
…mesh, and ingress controllers (#48966)

### What does this PR do?

Adds 22 new builtin CRD entries to the orchestrator explorer so Cloud Security can determine internet-reachability paths for k8s workloads. Uses a hybrid collection strategy: resource-specific entries for high-volume vendors (Istio, NGINX, Traefik) and group-level entries for less common vendors.

Three new per-family config flags (all **opt-in, default: false**):
- `orchestrator_explorer.custom_resources.ootb.gateway_api`
- `orchestrator_explorer.custom_resources.ootb.service_mesh`
- `orchestrator_explorer.custom_resources.ootb.ingress_controllers`

**New families:**
- **Gateway API** (5 resource-specific): gateways, httproutes, grpcroutes, tlsroutes, listenersets
- **Service mesh — Istio** (5 resource-specific): virtualservices, gateways, destinationrules, serviceentries, sidecars (with v1beta1 fallback)
- **Service mesh — others** (6 group-level): Envoy Gateway, Traefik (legacy), Linkerd, Consul, Consul Mesh, Kuma
- **Ingress controllers — NGINX** (2 resource-specific): virtualservers, virtualserverroutes
- **Ingress controllers — Traefik** (1 resource-specific): ingressroutes
- **Ingress controllers — others** (3 group-level): Kong, HAProxy Core, HAProxy v1

### Motivation

Cloud Security needs to tell customers which container workloads are internet-reachable. Today, the agent collects standard Ingress and Service objects, covering ~16% of EKS customers. Over 36% use service meshes or non-standard ingress controllers whose exposure paths go through CRDs we don't collect.

RFC: https://datadoghq.atlassian.net/wiki/x/4IOyfAE
Technical implementation: https://datadoghq.atlassian.net/wiki/x/EgO6fAE

### Describe how you validated your changes

- All existing tests pass: `TestNewBuiltinCRDConfigs`, `TestImportBuiltinCollectors`, `TestGetDatadogCustomResourceCollectors`, `TestFilterCRCollectorsByPermission`
- New test `TestNewBuiltinCRDConfigsPerFamilyFlags` verifies each per-family flag independently disables its family, and the global OOTB flag disables everything
- Package compiles cleanly with `go build -tags "kubeapiserver orchestrator"`

### Additional Notes

**All three flags default to `false` (opt-in).** Collection is only activated when RBAC is granted (via helm/operator) and the corresponding flag is set to `true`.

**Merge order:** The backend allowlist PR (dd-go) must be deployed before this PR merges, otherwise collected CRs will be silently dropped.

- [ ] Backend allowlist deployed: DataDog/dd-go#230589
- [ ] Helm chart RBAC merged: DataDog/helm-charts#2541
- [ ] Operator RBAC merged: DataDog/datadog-operator#2874

## Related PRs

| Repo | PR | Purpose |
|------|----|---------|
| DataDog/dd-go | DataDog/dd-go#230589 | Backend allowlist (deploy FIRST) |
| DataDog/helm-charts | DataDog/helm-charts#2541 | Helm chart RBAC |
| DataDog/datadog-operator | DataDog/datadog-operator#2874 | Operator RBAC |

Co-authored-by: eliott.bouhana <eliott.bouhana@datadoghq.com>
…agent

When networkCRDs.enabled=true, set all three per-family agent config flags
on the cluster-agent pod so collection is activated alongside the RBAC:
  DD_ORCHESTRATOR_EXPLORER_CUSTOM_RESOURCES_OOTB_GATEWAY_API=true
  DD_ORCHESTRATOR_EXPLORER_CUSTOM_RESOURCES_OOTB_SERVICE_MESH=true
  DD_ORCHESTRATOR_EXPLORER_CUSTOM_RESOURCES_OOTB_INGRESS_CONTROLLERS=true

These map to orchestrator_explorer.custom_resources.ootb.{gateway_api,
service_mesh,ingress_controllers} in the agent config (DataDog/datadog-agent#48966).
@eliottness eliottness marked this pull request as ready for review April 13, 2026 13:47
@eliottness eliottness requested a review from a team April 13, 2026 13:47
@eliottness eliottness requested review from a team as code owners April 13, 2026 13:47
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