Skip to content

[BUG] cluster-agent metricsProvider RoleBinding for extension-apiserver-authentication-reader created in wrong namespace #2571

Description

@noizo

Pre-submission Checklist

  • I have searched existing issues and this is not a duplicate
  • This is a Helm chart issue, not a Datadog product/service problem

Helm chart name

datadog

Helm chart version

3.88.3 - 3.160.2, current main as well

Bug Report

What happened:
When clusterAgent.metricsProvider.enabled: true and the chart is installed outside kube-system (e.g. datadog-system), the RoleBinding <release>-cluster-agent-apiserver is created in {{ .Release.Namespace }} but references the Role extension-apiserver-authentication-reader, which only exists in kube-system.

RoleBindings are namespace-scoped and can only reference Roles in the same namespace, so the binding silently does nothing. The Cluster Agent's external metrics API server (port 8443) cannot read the extension-apiserver-authentication ConfigMap and rejects all requests with 403 Forbidden:

RBAC: role.rbac.authorization.k8s.io "extension-apiserver-authentication-reader" not found

This breaks the DatadogMetric CRD flow — all DatadogMetric CRs remain Active: False, Valid: False indefinitely.

The bug is in charts/datadog/templates/cluster-agent-rbac.yaml:

apiVersion: {{ template "rbac.apiVersion" . }}
kind: RoleBinding
metadata:
  name: "{{ template "datadog.fullname" . }}-cluster-agent-apiserver"
  namespace: {{ .Release.Namespace }}          # <-- should be kube-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
  - kind: ServiceAccount
    name: {{ template "datadog.fullname" . }}-cluster-agent
    namespace: {{ .Release.Namespace }}

What I expected:
The RoleBinding should be created in kube-system where the extension-apiserver-authentication-reader Role exists. This is the standard pattern used by other extension API servers (metrics-server, KEDA).

Steps to Reproduce

  1. Install the chart in a namespace other than kube-system:
    helm install datadog datadog/datadog -n datadog-system --set clusterAgent.metricsProvider.enabled=true --set clusterAgent.metricsProvider.useDatadogMetrics=true
    
  2. Create a DatadogMetric CR
  3. Observe it stays Active: False, Valid: False indefinitely
  4. Verify the role is missing in the release namespace:
    kubectl get role extension-apiserver-authentication-reader -n kube-system      # exists
    kubectl get role extension-apiserver-authentication-reader -n datadog-system   # NotFound

Environment

Kubernetes version: v1.32 (EKS)
Helm version: v4.1.3
Cloud provider: AWS

Additional Context

This likely hasn't been widely reported because most deployments install Datadog in kube-system (where the Role exists) or use the Datadog Operator (which manages its own RBAC).

Suggested fix — change the namespace to kube-system:

apiVersion: {{ template "rbac.apiVersion" . }}
kind: RoleBinding
metadata:
  name: "{{ template "datadog.fullname" . }}-cluster-agent-apiserver"
  namespace: kube-system
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: Role
  name: extension-apiserver-authentication-reader
subjects:
  - kind: ServiceAccount
    name: {{ template "datadog.fullname" . }}-cluster-agent
    namespace: {{ .Release.Namespace }}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions