Skip to content

Commit

Permalink
Add talos support for os-release files (#1611)
Browse files Browse the repository at this point in the history
Co-authored-by: faelis <[email protected]>
  • Loading branch information
clamoriniere and faelis authored Dec 4, 2024
1 parent 19f1358 commit 54edc22
Show file tree
Hide file tree
Showing 14 changed files with 107 additions and 12 deletions.
6 changes: 6 additions & 0 deletions charts/datadog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
# Datadog changelog

## 3.83.0

* Added the configuration value `datadog.disablePasswdMount` to disable mounting the `/etc/passwd` path from the host filesystem. This option should be used when the underlying OS does not have these files (e.g., Talos OS).
* Added the configuration value `datadog.disableDefaultOsReleasePaths` to disable mounting the default "os-release" file paths from the host filesystem (e.g., `/etc/redhat-release`, `/etc/fedora-release`, etc.). Note that this change does not affect the `datadog.osReleasePath` option. To avoid mounting the `/etc/os-release` host path, set the `datadog.osReleasePath` configuration value to an empty string. This option should be used when the underlying OS does not have these files (e.g., Talos OS).
* Add `providers.talos.enabled` to simplify agent deployment configuration on Talos OS.

## 3.82.0

* Add `pods/exec` RBAC to the `Cluster-Agent` when needed and inject the service account name of the `Cluster-Agent` as environment variable.
Expand Down
3 changes: 2 additions & 1 deletion charts/datadog/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
---
apiVersion: v1
name: datadog
version: 3.82.0
version: 3.83.0
appVersion: "7"
description: Datadog Agent
keywords:
Expand Down
5 changes: 4 additions & 1 deletion charts/datadog/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Datadog

![Version: 3.82.0](https://img.shields.io/badge/Version-3.82.0-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)
![Version: 3.83.0](https://img.shields.io/badge/Version-3.83.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 @@ -727,6 +727,8 @@ helm install <RELEASE_NAME> \
| datadog.containerRuntimeSupport.enabled | bool | `true` | Set this to false to disable agent access to container runtime. |
| datadog.criSocketPath | string | `nil` | Path to the container runtime socket (if different from Docker) |
| datadog.dd_url | string | `nil` | The host of the Datadog intake server to send Agent data to, only set this option if you need the Agent to send data to a custom URL |
| datadog.disableDefaultOsReleasePaths | bool | `false` | Set this to true to disable mounting datadog.osReleasePath in all containers |
| datadog.disablePasswdMount | bool | `false` | Set this to true to disable mounting /etc/passwd in all containers |
| datadog.dockerSocketPath | string | `nil` | Path to the docker socket |
| datadog.dogstatsd.hostSocketPath | string | `"/var/run/datadog/"` | Host path to the DogStatsD socket |
| datadog.dogstatsd.nonLocalTraffic | bool | `true` | Enable this to make each node accept non-local statsd traffic (from outside of the pod) |
Expand Down Expand Up @@ -897,6 +899,7 @@ helm install <RELEASE_NAME> \
| providers.gke.autopilot | bool | `false` | Enables Datadog Agent deployment on GKE Autopilot |
| providers.gke.cos | bool | `false` | Enables Datadog Agent deployment on GKE with Container-Optimized OS (COS) |
| providers.gke.gdc | bool | `false` | Enables Datadog Agent deployment on GKE on Google Distributed Cloud (GDC) |
| providers.talos.enabled | bool | `false` | Activate all required specificities related to Talos.dev configuration, as currently the chart cannot auto-detect Talos.dev cluster. Note: The Agent deployment requires additional privileges that are not permitted by the default pod security policy. The annotation `pod-security.kubernetes.io/enforce=privileged` must be applied to the Datadog installation Kubernetes namespace. For more information on pod security policies in Talos.dev clusters, see: https://www.talos.dev/v1.8/kubernetes-guides/configuration/pod-security/ |
| registry | string | `nil` | Registry to use for all Agent images (default to [gcr.io | eu.gcr.io | asia.gcr.io | datadoghq.azurecr.io | public.ecr.aws/datadog] depending on datadog.site value) |
| remoteConfiguration.enabled | bool | `true` | Set to true to enable remote configuration on the Cluster Agent (if set) and the node agent. Can be overridden if `datadog.remoteConfiguration.enabled` Preferred way to enable Remote Configuration. |
| targetSystem | string | `"linux"` | Target OS for this deployment (possible values: linux, windows) |
Expand Down
4 changes: 4 additions & 0 deletions charts/datadog/ci/disable-defaultosreleasepath-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
datadog:
apiKey: "00000000000000000000000000000000"
appKey: "0000000000000000000000000000000000000000"
disableDefaultOsReleasePaths: true
8 changes: 8 additions & 0 deletions charts/datadog/ci/provider-talos-values.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
datadog:
apiKey: "00000000000000000000000000000000"
appKey: "0000000000000000000000000000000000000000"

providers:
talos:
enabled: true
19 changes: 19 additions & 0 deletions charts/datadog/templates/NOTES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,25 @@ More information about this change: https://github.com/DataDog/helm-charts/pull/
{{- end }}


{{- if and (eq .Values.targetSystem "linux") (eq .Values.datadog.osReleasePath "") (eq (include "should-add-host-path-for-os-release-paths" .) "false") .Values.datadog.sbom.host.enabled }}
#################################################################
#### ERROR: Configuration notice ####
#################################################################
The SBOM host filesystem collection feature requires access to the os-release information from the host.
`datadog.sbom.host.enabled: true` can't be used with `datadog.disableDefaultOsReleasePaths: true`.
{{- fail "The SBOM host filesystem collection feature requires access to the os-release information from the host." }}
{{- end }}

{{- if and (eq .Values.targetSystem "linux") (eq .Values.datadog.osReleasePath "") (eq (include "should-add-host-path-for-os-release-paths" .) "false") (eq (include "should-enable-system-probe" .) "true") }}
#################################################################
#### ERROR: Configuration notice ####
#################################################################
The current set of options used to install the chart requires the system-probe container to be enabled.
However, the `datadog.disableDefaultOsReleasePaths` option set to `true` and `datadog.osReleasePath` is empty which is not compatible when the system-probe container is required.
{{- fail "OS Release information is required when system-probe is enabled." }}
{{- end }}


{{- $hasContainerIncludeEnv := false }}
{{- range $key := .Values.datadog.env }}
{{- if eq $key.name "DD_CONTAINER_INCLUDE" }}
Expand Down
4 changes: 3 additions & 1 deletion charts/datadog/templates/_container-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@
mountPath: /host/sys/fs/cgroup
mountPropagation: {{ .Values.datadog.hostVolumeMountPropagation }}
readOnly: true
{{- if (eq (include "should-run-process-checks-on-core-agent" .) "true") }}
{{- if and (eq (include "should-add-host-path-for-etc-passwd" .) "true") (eq (include "should-run-process-checks-on-core-agent" .) "true") }}
- name: passwd
mountPath: /etc/passwd
readOnly: true
Expand Down Expand Up @@ -302,6 +302,7 @@
- name: host-rpm-dir
mountPath: /host/var/lib/rpm
readOnly: true
{{- if eq (include "should-add-host-path-for-os-release-paths" .) "true" }}
{{- if ne .Values.datadog.osReleasePath "/etc/redhat-release" }}
- name: etc-redhat-release
mountPath: /host/etc/redhat-release
Expand All @@ -324,6 +325,7 @@
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- if eq .Values.targetSystem "windows" }}
{{- if or .Values.datadog.logs.enabled .Values.datadog.logsEnabled }}
- name: pointerdir
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
{{- define "linux-container-host-release-volumemounts" -}}
{{- if not .Values.providers.gke.gdc }}
{{- if eq (include "should-enable-system-probe" .) "true" }}
{{- if or .Values.datadog.osReleasePath .Values.datadog.systemProbe.osReleasePath }}
{{- if and (not .Values.providers.gke.gdc) (not .Values.providers.gke.autopilot) }}
{{- if eq (include "should-enable-system-probe" .) "true" }}
- name: os-release-file
mountPath: /host{{ .Values.datadog.systemProbe.osReleasePath | default .Values.datadog.osReleasePath }}
readOnly: true
{{- else if not .Values.providers.gke.autopilot}}
{{- else if .Values.datadog.osReleasePath }}
- name: os-release-file
mountPath: /host{{ .Values.datadog.osReleasePath }}
readOnly: true
{{- end }}
{{- end }}
{{- end }}
{{- end }}
{{- end }}
2 changes: 1 addition & 1 deletion charts/datadog/templates/_container-process-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@
mountPath: /host/sys/fs/cgroup
mountPropagation: {{ .Values.datadog.hostVolumeMountPropagation }}
readOnly: true
{{- if or .Values.datadog.processAgent.processCollection .Values.datadog.processAgent.processDiscovery .Values.datadog.processAgent.containerCollection}}
{{- if and (eq (include "should-add-host-path-for-etc-passwd" .) "true") (or .Values.datadog.processAgent.processCollection .Values.datadog.processAgent.processDiscovery .Values.datadog.processAgent.containerCollection) }}
- name: passwd
mountPath: /etc/passwd
readOnly: true
Expand Down
2 changes: 2 additions & 0 deletions charts/datadog/templates/_container-security-agent.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,11 @@
- name: cgroups
mountPath: /host/sys/fs/cgroup
readOnly: true
{{- if (eq (include "should-add-host-path-for-etc-passwd" .) "true") }}
- name: passwd
mountPath: /etc/passwd
readOnly: true
{{- end }}
- name: group
mountPath: /etc/group
readOnly: true
Expand Down
2 changes: 1 addition & 1 deletion charts/datadog/templates/_container-system-probe.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@
mountPropagation: {{ .Values.datadog.hostVolumeMountPropagation }}
readOnly: true
{{- include "linux-container-host-release-volumemounts" . | nindent 4 }}
{{- if .Values.datadog.systemProbe.enableDefaultOsReleasePaths }}
{{- if (eq (include "should-add-host-path-for-os-release-paths" .) "true") }}
{{- if ne .Values.datadog.osReleasePath "/etc/redhat-release" }}
- name: etc-redhat-release
mountPath: /host/etc/redhat-release
Expand Down
4 changes: 2 additions & 2 deletions charts/datadog/templates/_daemonset-volumes-linux.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
path: {{ .Values.datadog.systemProbe.osReleasePath | default .Values.datadog.osReleasePath }}
name: os-release-file
{{- end }}
{{- if or (and (eq (include "should-enable-system-probe" .) "true") .Values.datadog.systemProbe.enableDefaultOsReleasePaths) .Values.datadog.sbom.host.enabled }}
{{- if and (eq (include "should-add-host-path-for-os-release-paths" .) "true") (or (eq (include "should-enable-system-probe" .) "true") .Values.datadog.sbom.host.enabled) }}
- hostPath:
path: /etc/redhat-release
name: etc-redhat-release
Expand Down Expand Up @@ -138,7 +138,7 @@
name: btf-path
{{- end }}
{{- end }}
{{- if or (eq (include "process-checks-enabled" .) "true") (eq (include "should-run-process-checks-on-core-agent" .) "true") (eq (include "should-enable-system-probe" .) "true") (eq (include "should-enable-security-agent" .) "true") }}
{{- if and (eq (include "should-add-host-path-for-etc-passwd" .) "true") (or (eq (include "process-checks-enabled" .) "true") (eq (include "should-run-process-checks-on-core-agent" .) "true") (eq (include "should-enable-system-probe" .) "true") (eq (include "should-enable-security-agent" .) "true")) }}
- hostPath:
path: /etc/passwd
name: passwd
Expand Down
34 changes: 33 additions & 1 deletion charts/datadog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -891,7 +891,7 @@ false
Returns whether Remote Configuration should be enabled in the agent
*/}}
{{- define "datadog-remoteConfiguration-enabled" -}}
{{- if and (.Values.remoteConfiguration.enabled) (.Values.datadog.remoteConfiguration.enabled) (not .Values.providers.gke.gdc ) -}}
{{- if and (.Values.remoteConfiguration.enabled) (.Values.datadog.remoteConfiguration.enabled) (not .Values.providers.gke.gdc) -}}
true
{{- else -}}
false
Expand Down Expand Up @@ -1045,3 +1045,35 @@ Create RBACs for custom resources
{{- end -}}
{{- end -}}
{{- end -}}


{{/*
Returns true if Host paths for default OS Release Paths need to be added to the volumes.
*/}}
{{- define "should-add-host-path-for-os-release-paths" -}}
{{- if ne .Values.targetSystem "linux" -}}
false
{{- else if .Values.providers.talos.enabled -}}
false
{{- else if (and .Values.datadog.systemProbe.enableDefaultOsReleasePaths (not .Values.datadog.disableDefaultOsReleasePaths)) -}}
true
{{- else -}}
false
{{- end -}}
{{- end -}}


{{/*
Returns true if the host file /etc/passwd should be mounted, else return false.
*/}}
{{- define "should-add-host-path-for-etc-passwd" -}}
{{- if ne .Values.targetSystem "linux" -}}
false
{{- else if .Values.providers.talos.enabled -}}
false
{{- else if not .Values.datadog.disablePasswdMount -}}
true
{{- else -}}
false
{{- end -}}
{{- end -}}
16 changes: 16 additions & 0 deletions charts/datadog/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -698,6 +698,12 @@ datadog:
## ref: https://docs.datadoghq.com/infrastructure/containers/?tab=helm
containerCollection: true

# datadog.disableDefaultOsReleasePaths -- Set this to true to disable mounting datadog.osReleasePath in all containers
disableDefaultOsReleasePaths: false

# datadog.disablePasswdMount -- Set this to true to disable mounting /etc/passwd in all containers
disablePasswdMount: false

# datadog.osReleasePath -- Specify the path to your os-release file
osReleasePath: /etc/os-release

Expand Down Expand Up @@ -759,6 +765,7 @@ datadog:
# datadog.systemProbe.conntrackInitTimeout -- the time to wait for conntrack to initialize before failing
conntrackInitTimeout: 10s

# DEPRECATED. Use datadog.disableDefaultOsReleasePaths instead.
# datadog.systemProbe.enableDefaultOsReleasePaths -- enable default os-release files mount
enableDefaultOsReleasePaths: true

Expand Down Expand Up @@ -2315,6 +2322,15 @@ providers:
# providers.aks.enabled -- Activate all specificities related to AKS configuration. Required as currently we cannot auto-detect AKS.
enabled: false

talos:
# providers.talos.enabled -- Activate all required specificities related to Talos.dev configuration,
# as currently the chart cannot auto-detect Talos.dev cluster.
# Note: The Agent deployment requires additional privileges that are not permitted by the default pod security policy.
# The annotation `pod-security.kubernetes.io/enforce=privileged` must be applied to the Datadog installation
# Kubernetes namespace. For more information on pod security policies in Talos.dev clusters, see:
# https://www.talos.dev/v1.8/kubernetes-guides/configuration/pod-security/
enabled: false

remoteConfiguration:
# remoteConfiguration.enabled -- Set to true to enable remote configuration on the Cluster Agent (if set) and the node agent.
# Can be overridden if `datadog.remoteConfiguration.enabled`
Expand Down

0 comments on commit 54edc22

Please sign in to comment.