Skip to content

Commit

Permalink
[APM Onboarding] Disable APM Instrumentation on Datadog namespace (#1252
Browse files Browse the repository at this point in the history
)

* Disable APM Instrumentation on Datadog namespace

* Add empty line to .helpers

* Normalize disabledNamespaces to list

* Remove datadog namespace from enabledNamespaces list

* Fix usage of .Release.Namespace

* Fix enabledNamespaces option

* Revert values.yaml to correct default values
  • Loading branch information
liliyadd authored Nov 21, 2023
1 parent 0fe1957 commit e18b2b7
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 7 deletions.
4 changes: 4 additions & 0 deletions charts/datadog/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Datadog changelog

## 3.49.4

* Exclude a namespace with Datadog resources from APM Single Step Instrumentation

## 3.49.3

* Fix NOTES warning for APM Instrumentation when apm.intrumentation.disabledNamespaces is set
Expand Down
2 changes: 1 addition & 1 deletion charts/datadog/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v1
name: datadog
version: 3.49.3
version: 3.49.4
appVersion: "7"
description: Datadog Agent
keywords:
Expand Down
2 changes: 1 addition & 1 deletion charts/datadog/README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Datadog

![Version: 3.49.3](https://img.shields.io/badge/Version-3.49.3-informational?style=flat-square) ![AppVersion: 7](https://img.shields.io/badge/AppVersion-7-informational?style=flat-square)
![Version: 3.49.4](https://img.shields.io/badge/Version-3.49.4-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
32 changes: 32 additions & 0 deletions charts/datadog/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -893,3 +893,35 @@ Create RBACs for custom resources
false
{{- end -}}
{{- end -}}

{{/*
Return all namespaces with enabled Single Step Instrumentation. If instrumentation.enabledNamespaces contains the namespace where Datadog is installed,
it will be removed.
*/}}
{{- define "apmInstrumentation.enabledNamespaces" -}}
{{- if and .Values.datadog.apm .Values.datadog.apm.instrumentation -}}
{{- if and .Values.datadog.apm.instrumentation.enabledNamespaces (not .Values.datadog.apm.instrumentation.enabled) -}}
{{- if has .Release.Namespace .Values.datadog.apm.instrumentation.enabledNamespaces -}}
{{- $ns := mustWithout .Values.datadog.apm.instrumentation.enabledNamespaces .Release.Namespace -}}
{{- if $ns -}}
{{- $ns | toJson | quote -}}
{{- end -}}
{{- else -}}
{{- .Values.datadog.apm.instrumentation.enabledNamespaces | toJson | quote -}}
{{- end -}}
{{- end -}}
{{- end -}}
{{- end -}}

{{/*
Return all namespaces with disabled Single Step Instrumentation
*/}}
{{- define "apmInstrumentation.disabledNamespaces" -}}
{{- if and .Values.datadog.apm .Values.datadog.apm.instrumentation -}}
{{- if and .Values.datadog.apm.instrumentation.disabledNamespaces .Values.datadog.apm.instrumentation.enabled -}}
{{- append .Values.datadog.apm.instrumentation.disabledNamespaces .Release.Namespace | toJson | quote -}}
{{- else if .Values.datadog.apm.instrumentation.enabled -}}
{{- list .Release.Namespace | toJson | quote -}}
{{- end -}}
{{- end -}}
{{- end -}}
10 changes: 5 additions & 5 deletions charts/datadog/templates/cluster-agent-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -236,17 +236,17 @@ spec:
{{- end }}
- name: DD_REMOTE_CONFIGURATION_ENABLED
value: {{ include "clusterAgent-remoteConfiguration-enabled" . | quote }}
{{- if .Values.datadog.apm.instrumentation.enabled }}
{{- if .Values.datadog.apm.instrumentation.enabled }}
- name: DD_APM_INSTRUMENTATION_ENABLED
value: "true"
{{- end }}
{{- if .Values.datadog.apm.instrumentation.enabledNamespaces }}
{{- if ne (include "apmInstrumentation.enabledNamespaces" .) "" }}
- name: DD_APM_INSTRUMENTATION_ENABLED_NAMESPACES
value: {{ .Values.datadog.apm.instrumentation.enabledNamespaces | toJson | quote }}
value: {{ include "apmInstrumentation.enabledNamespaces" . }}
{{- end }}
{{- if .Values.datadog.apm.instrumentation.disabledNamespaces }}
{{- if ne (include "apmInstrumentation.disabledNamespaces" .) "" }}
- name: DD_APM_INSTRUMENTATION_DISABLED_NAMESPACES
value: {{ .Values.datadog.apm.instrumentation.disabledNamespaces | toJson | quote }}
value: {{ include "apmInstrumentation.disabledNamespaces" . }}
{{- end }}
{{- if .Values.datadog.apm.instrumentation.libVersions }}
- name: DD_APM_INSTRUMENTATION_LIB_VERSIONS
Expand Down

0 comments on commit e18b2b7

Please sign in to comment.