From a9c78da50dbadd228b1e12d14c2459efa6e57dbc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Fri, 24 Apr 2020 17:08:06 +0200 Subject: [PATCH] [stable/datadog] Ensure the `trace-agent` computes the same hostname as the core `agent` (#22110) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit by giving it access to all the elements that might be used to compute the hostname: the `DD_CLUSTER_NAME` environment variable and the docker socket. Signed-off-by: Lénaïc Huard --- stable/datadog/CHANGELOG.md | 10 ++++++++++ stable/datadog/Chart.yaml | 2 +- stable/datadog/templates/container-agent.yaml | 20 ------------------- .../templates/container-trace-agent.yaml | 5 +++++ .../templates/containers-common-env.yaml | 20 +++++++++++++++++++ .../templates/containers-init-linux.yaml | 8 -------- .../templates/containers-init-windows.yaml | 8 -------- 7 files changed, 36 insertions(+), 37 deletions(-) diff --git a/stable/datadog/CHANGELOG.md b/stable/datadog/CHANGELOG.md index e7abb24008..83d0890c3c 100644 --- a/stable/datadog/CHANGELOG.md +++ b/stable/datadog/CHANGELOG.md @@ -1,5 +1,15 @@ # Datadog changelog +## 2.2.6 + +* Ensure the `trace-agent` computes the same hostname as the core `agent`. + by giving it access to all the elements that might be used to compute the hostname: + the `DD_CLUSTER_NAME` environment variable and the docker socket. + +## 2.2.5 + +* Fix RBAC + ## 2.2.4 * Move several EnvVars to `common-env-vars` to be accessible by the `trace-agent` #21991. diff --git a/stable/datadog/Chart.yaml b/stable/datadog/Chart.yaml index 5ef2b1cda9..72bc077363 100644 --- a/stable/datadog/Chart.yaml +++ b/stable/datadog/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: datadog -version: 2.2.5 +version: 2.2.6 appVersion: "7" description: Datadog Agent keywords: diff --git a/stable/datadog/templates/container-agent.yaml b/stable/datadog/templates/container-agent.yaml index 0583c2e6a1..6cce6b3919 100644 --- a/stable/datadog/templates/container-agent.yaml +++ b/stable/datadog/templates/container-agent.yaml @@ -14,13 +14,6 @@ protocol: UDP env: {{- include "containers-common-env" . | nindent 4 }} - {{- if .Values.datadog.clusterName }} - {{- if not (regexMatch "^([a-z]([a-z0-9\\-]{0,38}[a-z0-9])?\\.)*([a-z]([a-z0-9\\-]{0,38}[a-z0-9])?)$" .Values.datadog.clusterName) }} - {{- fail "Your `clusterName` isn’t valid. It must be dot-separated tokens where a token start with a lowercase letter followed by up to 39 lowercase letters, numbers, or hyphens and cannot end with a hyphen."}} - {{- end}} - - name: DD_CLUSTER_NAME - value: {{ .Values.datadog.clusterName | quote }} - {{- end }} {{- if .Values.datadog.logLevel }} - name: DD_LOG_LEVEL value: {{ .Values.agents.containers.agent.logLevel | default .Values.datadog.logLevel | quote }} @@ -77,19 +70,6 @@ value: {{ (default false (or .Values.datadog.logs.containerCollectAll .Values.datadog.logsConfigContainerCollectAll)) | quote}} - name: DD_LOGS_CONFIG_K8S_CONTAINER_USE_FILE value: {{ .Values.datadog.logs.containerCollectUsingFiles | quote }} - {{- if .Values.datadog.dockerSocketPath }} - - name: DOCKER_HOST - {{- if eq .Values.targetSystem "linux" }} - value: unix://{{ .Values.datadog.dockerSocketPath }} - {{- end }} - {{- if eq .Values.targetSystem "windows" }} - value: npipe://{{ .Values.datadog.dockerSocketPath | replace "\\" "/" }} - {{- end }} - {{- end }} - {{- if .Values.datadog.criSocketPath }} - - name: DD_CRI_SOCKET_PATH - value: {{ .Values.datadog.criSocketPath }} - {{- end }} {{- if not .Values.datadog.livenessProbe }} - name: DD_HEALTH_PORT value: "5555" diff --git a/stable/datadog/templates/container-trace-agent.yaml b/stable/datadog/templates/container-trace-agent.yaml index 086498b3a7..ae119414c1 100644 --- a/stable/datadog/templates/container-trace-agent.yaml +++ b/stable/datadog/templates/container-trace-agent.yaml @@ -37,6 +37,11 @@ mountPath: {{ template "datadog.confPath" . }}/datadog.yaml subPath: datadog.yaml {{- end }} + - name: runtimesocket + mountPath: {{ template "datadog.dockerOrCriSocketPath" . }} + {{- if eq .Values.targetSystem "linux" }} + readOnly: true + {{- end }} livenessProbe: {{ toYaml .Values.agents.containers.traceAgent.livenessProbe | indent 4 }} {{- end -}} diff --git a/stable/datadog/templates/containers-common-env.yaml b/stable/datadog/templates/containers-common-env.yaml index d1e6be3c52..feec8695ed 100644 --- a/stable/datadog/templates/containers-common-env.yaml +++ b/stable/datadog/templates/containers-common-env.yaml @@ -16,6 +16,13 @@ - name: DD_HOSTNAME value: {{ .Values.datadog.hostname | quote }} {{- end }} +{{- if .Values.datadog.clusterName }} +{{- if not (regexMatch "^([a-z]([a-z0-9\\-]{0,38}[a-z0-9])?\\.)*([a-z]([a-z0-9\\-]{0,38}[a-z0-9])?)$" .Values.datadog.clusterName) }} +{{- fail "Your `clusterName` isn’t valid. It must be dot-separated tokens where a token start with a lowercase letter followed by up to 39 lowercase letters, numbers, or hyphens and cannot end with a hyphen."}} +{{- end}} +- name: DD_CLUSTER_NAME + value: {{ .Values.datadog.clusterName | quote }} +{{- end }} {{- if .Values.datadog.tags }} - name: DD_TAGS value: {{ .Values.datadog.tags | join " " | quote }} @@ -46,4 +53,17 @@ - name: {{ $value.name }} value: {{ $value.value | quote }} {{- end }} +{{- if .Values.datadog.dockerSocketPath }} +- name: DOCKER_HOST +{{- if eq .Values.targetSystem "linux" }} + value: unix://{{ .Values.datadog.dockerSocketPath }} +{{- end }} +{{- if eq .Values.targetSystem "windows" }} + value: npipe://{{ .Values.datadog.dockerSocketPath | replace "\\" "/" }} +{{- end }} +{{- end }} +{{- if .Values.datadog.criSocketPath }} +- name: DD_CRI_SOCKET_PATH + value: {{ .Values.datadog.criSocketPath }} +{{- end }} {{- end -}} diff --git a/stable/datadog/templates/containers-init-linux.yaml b/stable/datadog/templates/containers-init-linux.yaml index e3661caa0a..49a71dd587 100644 --- a/stable/datadog/templates/containers-init-linux.yaml +++ b/stable/datadog/templates/containers-init-linux.yaml @@ -43,14 +43,6 @@ value: {{ .Values.datadog.leaderElection | quote }} {{- end }} {{- end }} - {{- if .Values.datadog.dockerSocketPath }} - - name: DOCKER_HOST - value: unix://{{ .Values.datadog.dockerSocketPath }} - {{- end }} - {{- if .Values.datadog.criSocketPath }} - - name: DD_CRI_SOCKET_PATH - value: {{ .Values.datadog.criSocketPath }} - {{- end }} resources: {{ toYaml .Values.agents.containers.initContainers.resources | indent 4 }} {{- end -}} diff --git a/stable/datadog/templates/containers-init-windows.yaml b/stable/datadog/templates/containers-init-windows.yaml index 24ca4aa0ec..e5ae9ec888 100644 --- a/stable/datadog/templates/containers-init-windows.yaml +++ b/stable/datadog/templates/containers-init-windows.yaml @@ -33,14 +33,6 @@ mountPath: {{ template "datadog.dockerOrCriSocketPath" . }} env: {{- include "containers-common-env" . | nindent 4 }} - {{- if .Values.datadog.dockerSocketPath }} - - name: DOCKER_HOST - value: npipe://{{ .Values.datadog.dockerSocketPath | replace "\\" "/" }} - {{- end }} - {{- if .Values.datadog.criSocketPath }} - - name: DD_CRI_SOCKET_PATH - value: {{ .Values.datadog.criSocketPath }} - {{- end }} resources: {{ toYaml .Values.agents.containers.initContainers.resources | indent 4 }} {{- end -}}