Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

OTAGENT-254 Add support for enhanced RBAC permissions for otel-agent #1693

Merged
merged 2 commits into from
Mar 6, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions charts/datadog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Datadog changelog

## 3.104.0

* Add `datadog.otelCollector.rbac.create` to control creation additional ClusterRole for `otel-agent` required by Kubernetes Attributes processor.
* Add `datadog.otelCollector.rbac.rules` to support additional RBAC permissions required by OTel components that are not included by default with `otel-agent`.

## 3.103.1

* Update `fips.image.tag` to `1.1.8` fixing CVEs
Expand Down
2 changes: 1 addition & 1 deletion charts/datadog/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
---
apiVersion: v1
name: datadog
version: 3.103.1
version: 3.104.0
appVersion: "7"
description: Datadog Agent
keywords:
Expand Down
4 changes: 3 additions & 1 deletion charts/datadog/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Datadog

![Version: 3.103.1](https://img.shields.io/badge/Version-3.103.1-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)
![Version: 3.104.0](https://img.shields.io/badge/Version-3.104.0-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)

[Datadog](https://www.datadoghq.com/) is a hosted infrastructure monitoring platform. This chart adds the Datadog Agent to all nodes in your cluster via a DaemonSet. It also optionally depends on the [kube-state-metrics chart](https://github.com/prometheus-community/helm-charts/tree/main/charts/kube-state-metrics). For more information about monitoring Kubernetes with Datadog, please refer to the [Datadog documentation website](https://docs.datadoghq.com/agent/basic_agent_usage/kubernetes/).

Expand Down Expand Up @@ -810,6 +810,8 @@ helm install <RELEASE_NAME> \
| datadog.otelCollector.config | string | `nil` | OTel collector configuration |
| datadog.otelCollector.enabled | bool | `false` | Enable the OTel Collector |
| datadog.otelCollector.ports | list | `[{"containerPort":"4317","name":"otel-grpc"},{"containerPort":"4318","name":"otel-http"}]` | Ports that OTel Collector is listening |
| datadog.otelCollector.rbac.create | bool | `true` | If true, check OTel Collector config for k8sattributes processor and create required ClusterRole to access Kubernetes API |
| datadog.otelCollector.rbac.rules | list | `[]` | A set of additional RBAC rules to apply to OTel Collector's ClusterRole |
| datadog.otlp.logs.enabled | bool | `false` | Enable logs support in the OTLP ingest endpoint |
| datadog.otlp.receiver.protocols.grpc.enabled | bool | `false` | Enable the OTLP/gRPC endpoint |
| datadog.otlp.receiver.protocols.grpc.endpoint | string | `"0.0.0.0:4317"` | OTLP/gRPC endpoint |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
targetSystem: "linux"
agents:
image:
repository: datadog/agent-dev
tag: nightly-ot-beta-main
doNotCheckTag: true
containers:
agent:
env:
- name: DD_HOSTNAME
value: "datadog"
datadog:
apiKey: "00000000000000000000000000000000"
appKey: "0000000000000000000000000000000000000000"
otelCollector:
enabled: true
rbac:
create: true
rules:
- apiGroups: [""]
resources: ["nodes"]
verbs: ["get", "watch", "list"]
config: |
processors:
k8sattributes/passthrough:
passthrough: true
k8sattributes:
receivers:
otlp:
exporters:
datadog:
api:
key: "00000000000000000000000000000000"
service:
pipelines:
traces:
receivers: [otlp]
processors: [k8sattributes]
exporters: [datadog]
metrics:
receivers: [otlp]
processors: [k8sattributes]
exporters: [datadog]
logs:
receivers: [otlp]
processors: [k8sattributes]
exporters: [datadog]
41 changes: 41 additions & 0 deletions charts/datadog/ci/agent-otel-collector-with-rbac-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
targetSystem: "linux"
agents:
image:
repository: datadog/agent-dev
tag: nightly-ot-beta-main
doNotCheckTag: true
containers:
agent:
env:
- name: DD_HOSTNAME
value: "datadog"
datadog:
apiKey: "00000000000000000000000000000000"
appKey: "0000000000000000000000000000000000000000"
otelCollector:
enabled: true
config: |
processors:
k8sattributes:
k8sattributes/passthrough:
passthrough: true
receivers:
otlp:
exporters:
datadog:
api:
key: "00000000000000000000000000000000"
service:
pipelines:
traces:
receivers: [otlp]
processors: [k8sattributes]
exporters: [datadog]
metrics:
receivers: [otlp]
processors: [k8sattributes]
exporters: [datadog]
logs:
receivers: [otlp]
processors: [k8sattributes]
exporters: [datadog]
16 changes: 16 additions & 0 deletions charts/datadog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,22 @@ false
{{- end -}}
{{- end -}}

{{/*
Return true if k8sattributes RBAC rules should be added to the OTel Agent ClusterRole
*/}}
{{- define "should-add-otel-agent-k8sattributes-rules" -}}
{{- $return := false }}
{{- $config := .Values.datadog.otelCollector.config | default "" | fromYaml }}
{{- range $key, $val := $config.processors }}
{{- if hasPrefix "k8sattributes" $key }}
{{- if or (empty $val) (empty $val.passthrough) }}
{{- $return = true }}
{{- end }}
{{- end }}
{{- end }}
{{- $return }}
{{- end -}}

{{/*
Return secret name to be used based on provided values.
*/}}
Expand Down
40 changes: 40 additions & 0 deletions charts/datadog/templates/otel-agent-rbac.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
{{- if and .Values.agents.rbac.create (eq (include "should-enable-otel-agent" .) "true") .Values.datadog.otelCollector.rbac.create -}}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to reviewers: should-enable-otel-agent defined here

{{- if or (eq (include "should-add-otel-agent-k8sattributes-rules" .) "true") .Values.datadog.otelCollector.rbac.rules -}}
apiVersion: {{ template "rbac.apiVersion" . }}
kind: ClusterRole
metadata:
name: {{ template "datadog.fullname" . }}-otel-agent
labels:
{{ include "datadog.labels" . | indent 4 }}
rules:
{{- if eq (include "should-add-otel-agent-k8sattributes-rules" .) "true" }}
- apiGroups: [""]
resources: ["pods", "namespaces"]
verbs: ["get", "watch", "list"]
- apiGroups: ["apps"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
- apiGroups: ["extensions"]
resources: ["replicasets"]
verbs: ["get", "list", "watch"]
{{- end -}}
{{- if .Values.datadog.otelCollector.rbac.rules -}}
{{ toYaml .Values.datadog.otelCollector.rbac.rules | nindent 2 -}}
{{- end }}
---
apiVersion: {{ template "rbac.apiVersion" . }}
kind: ClusterRoleBinding
metadata:
name: {{ template "datadog.fullname" . }}-otel-agent
labels:
{{ include "datadog.labels" . | indent 4 }}
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: {{ template "datadog.fullname" . }}-otel-agent
subjects:
- kind: ServiceAccount
name: {{ include "agents.serviceAccountName" . }}
namespace: {{ .Release.Namespace }}
{{- end -}}
{{- end -}}
11 changes: 11 additions & 0 deletions charts/datadog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -604,6 +604,17 @@ datadog:
# datadog.otelCollector.config -- OTel collector configuration
config: null

## Provide OTel Collector RBAC configuration
rbac:
# datadog.otelCollector.rbac.create -- If true, check OTel Collector config for k8sattributes processor
# and create required ClusterRole to access Kubernetes API
create: true
# datadog.otelCollector.rbac.rules -- A set of additional RBAC rules to apply to OTel Collector's ClusterRole
rules: []
# - apiGroups: [""]
# resources: ["pods", "nodes"]
# verbs: ["get", "list", "watch"]

## Continuous Profiler configuration
##
## Continuous Profiler is disabled by default and can be enabled by setting the `enabled` field to
Expand Down
Loading