Skip to content

Commit

Permalink
breaking changes now incorporated into consul.validateExtraConfig hel…
Browse files Browse the repository at this point in the history
…per template function as precheck
  • Loading branch information
natemollica-nm committed Feb 9, 2024
1 parent 2dc237b commit e4a234a
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 14 deletions.
6 changes: 2 additions & 4 deletions .changelog/3383.txt
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
```release-note:feature
breaking-change: users who previously had agent `enable_debug` set in `global.server.extraConfig`, should remove the extraConfig entry to avoid configuration conflicts.
breaking-change: users who previously had agent `telemetry` stanza settings for `disable_hostname`, `enable_host_metrics`, `prefix_filter`, `dogstatsd_addr`, and/or `dogstatsd_tags`, should remove the extraConfig entry/entries to avoid configuration conflicts.
helm: introduces `global.metrics.datadog` overrides to streamline consul-k8s datadog integration.
helm: introduces `global.metrics.enableConsulAgentDebug` to expose agent [`enable_debug`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#enable_debug) configuration.
helm: introduces `server.enableAgentDebug` to expose agent [`enable_debug`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#enable_debug) configuration.
helm: introduces `global.metrics.disableAgentHostName` to expose agent [`telemetry.disable_hostname`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-disable_hostname) configuration.
helm: introduces `global.metrics.enableHostMetrics` to expose agent [`telemetry.enable_host_metrics`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-enable_host_metrics) configuration.
helm: introduces `global.metrics.prefixFilter` to expose agent [`telemetry.prefix_filter`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-prefix_filter) configuration.
helm: introduces `global.metrics.datadog.dogstatsd.dogstatsdAddr` to expose agent [`telemetry.dogstatsd_addr`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-dogstatsd_addr) configuration.
helm: introduces `global.metrics.datadog.dogstatsd.dogstatsdTags` to expose agent [`telemetry.dogstatsd_tags`](https://developer.hashicorp.com/consul/docs/agent/config/config-files#telemetry-dogstatsd_tags) configuration.
helm: introduces required `ad.datadoghq.com/` annotations and `tags.datadoghq.com/` labels for integration with [Datadog Autodiscovery](https://docs.datadoghq.com/integrations/consul/?tab=containerized) and [Datadog Unified Service Tagging](https://docs.datadoghq.com/getting_started/tagging/unified_service_tagging/?tab=kubernetes#serverless-environment) for Consul.
helm: introduces automated unix domain socket hostPath mounting for containerized integration with datadog within consul-server statefulset.
helm: introduces `global.metrics.datadog.datadogOpenTelemetryCollector` override options to allow OTLP metrics forwarding to Datadog Agent.
helm: introduces `global.metrics.datadog.otlp` override options to allow OTLP metrics forwarding to Datadog Agent.
control-plane: adds `server-acl-init` datadog agent token creation for datadog integration.
```
46 changes: 44 additions & 2 deletions charts/consul/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,48 @@ is passed to consul as a -config-file param on command line.
[ -n "${HOSTNAME}" ] && sed -Ei "s|HOSTNAME|${HOSTNAME?}|g" /consul/extra-config/extra-from-values.json
{{- end -}}

{{/*
Cleanup server.extraConfig entries to avoid conflicting entries:
- server.enableAgentDebug:
- `enable_debug` should not exist in extraConfig
- metrics.disableAgentHostName:
- if global.metrics.enabled and global.metrics.enableAgentMetrics are enabled, `disable_hostname` should not exist in extraConfig
- metrics.enableHostMetrics:
- if global.metrics.enabled and global.metrics.enableAgentMetrics are enabled, `enable_host_metrics` should not exist in extraConfig
- metrics.prefixFilter
- if global.metrics.enabled and global.metrics.enableAgentMetrics are enabled, `prefix_filter` should not exist in extraConfig
- metrics.datadog.enabled:
- if global.metrics.datadog.enabled and global.metrics.datadog.dogstatsd.enabled, `dogstatsd_tags` and `dogstatsd_addr` should not exist in extraConfig
Usage: {{ template "consul.validateExtraConfig" . }}
*/}}
{{- define "consul.validateExtraConfig" -}}
{{- if (and .Values.global.metrics.enabled .Values.global.metrics.enableAgentMetrics) }}
{{- if (contains "enable_debug" .Values.server.extraConfig) }}
{{ fail "The 'enable_debug' key is present in extra-from-values.json. Use 'server.enableAgentDebug' to set this value." }}
{{- end }}
{{- if (contains "disable_hostname" .Values.server.extraConfig) }}
{{ fail "The 'disable_hostname' key is present in extra-from-values.json. Use 'global.metrics.disableAgentHostName' to set this value." }}
{{- end }}
{{- if (contains "enable_host_metrics" .Values.server.extraConfig) }}
{{ fail "The 'enable_host_metrics' key is present in extra-from-values.json. Use 'global.metrics.enableHostMetrics' to set this value." }}
{{- end }}
{{- if (contains "prefix_filter" .Values.server.extraConfig) }}
{{ fail "The 'prefix_filter' key is present in extra-from-values.json. Use 'global.metrics.prefix_filter' to set this value." }}
{{- end }}
{{- if (and .Values.global.metrics.datadog.dogstatsd.enabled) }}
{{- if (contains "dogstatsd_tags" .Values.server.extraConfig) }}
{{ fail "The 'dogstatsd_tags' key is present in extra-from-values.json. Use 'global.metrics.datadog.dogstatsd.dogstatsdTags' to set this value." }}
{{- end }}
{{- end }}
{{- if (and .Values.global.metrics.datadog.dogstatsd.enabled) }}
{{- if (contains "dogstatsd_addr" .Values.server.extraConfig) }}
{{ fail "The 'dogstatsd_addr' key is present in extra-from-values.json. Use 'global.metrics.datadog.dogstatsd.dogstatsd_addr' to set this value." }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}

{{/*
Create chart name and version as used by the chart label.
*/}}
Expand Down Expand Up @@ -589,8 +631,8 @@ Usage: {{ template "consul.validateDatadogConfiguration" . }}
{{- if and .Values.global.metrics.datadog.enabled (or (not .Values.global.metrics.enableAgentMetrics) (not .Values.global.metrics.enabled) )}}
{{fail "When enabling datadog metrics collection, the /v1/agent/metrics is required to be accessible, therefore global.metrics.enableAgentMetrics and global.metrics.enabled must be also be enabled."}}
{{- end }}
{{- if and .Values.global.metrics.datadog.dogstatsd.enabled .Values.global.metrics.datadog.otlp.enabled }}
{{fail "You must have one of DogStatsD (global.metrics.datadog.dogstatsd.enabled) or OpenMetrics (global.metrics.datadog.otlp.enabled) enabled, not both as this is an unsupported configuration." }}
{{- if and .Values.global.metrics.datadog.dogstatsd.enabled .Values.global.metrics.datadog.openMetricsPrometheus.enabled }}
{{fail "You must have one of DogStatsD (global.metrics.datadog.dogstatsd.enabled) or OpenMetrics (global.metrics.datadog.openMetricsPrometheus.enabled) enabled, not both as this is an unsupported configuration." }}
{{- end }}
{{- if and .Values.global.metrics.datadog.otlp.enabled (not .Values.telemetryCollector.enabled) }}
{{fail "Cannot enable Datadog OTLP metrics collection (global.metrics.datadog.otlp.enabled) without consul-telemetry-collector. Ensure Consul OTLP collection is enabled (telemetryCollector.enabled) and configured." }}
Expand Down
3 changes: 2 additions & 1 deletion charts/consul/templates/server-statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
{{ template "consul.validateCloudSecretKeys" . }}
{{ template "consul.validateMetricsConfig" . }}
{{ template "consul.validateDatadogConfiguration" . }}
{{ template "consul.validateExtraConfig" . }}
# StatefulSet to run the actual Consul server cluster.
apiVersion: apps/v1
kind: StatefulSet
Expand Down Expand Up @@ -143,7 +144,7 @@ spec:
{{- if .Values.global.metrics.datadog.enabled }}
"ad.datadoghq.com/tolerate-unready": "true"
"ad.datadoghq.com/consul.logs": {{ .Values.global.metrics.datadog.dogstatsd.dogstatsdTags | squote }}
{{- if .Values.global.metrics.datadog.otlp.enabled }}
{{- if .Values.global.metrics.datadog.openMetricsPrometheus.enabled }}
"ad.datadoghq.com/consul.checks": |
{
"openmetrics": {
Expand Down
2 changes: 1 addition & 1 deletion charts/consul/test/unit/server-config-configmap.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1310,7 +1310,7 @@ load _helpers
}

#--------------------------------------------------------------------
# Datadog Consul on Kubernetes Integration
# Datadog

@test "server/ConfigMap: when global.metrics.datadog.enabled=true, sets default telemetry.dogstatsd_addr config" {
cd `chart_dir`
Expand Down
12 changes: 6 additions & 6 deletions charts/consul/test/unit/server-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -899,15 +899,15 @@ load _helpers
[ "${actual}" = "ENC[k8s_secret@default/default-datadog-agent-metrics-acl-token/token]" ]
}

@test "server/StatefulSet: when global.metrics.datadog.otlp.enabled, applicable openmetrics annotation is set" {
@test "server/StatefulSet: when global.metrics.datadog.openMetricsPrometheus.enabled, applicable openmetrics annotation is set" {
cd `chart_dir`
local annotations=$(helm template \
-s templates/server-statefulset.yaml \
--set 'global.metrics.enabled=true' \
--set 'telemetryCollector.enabled=true' \
--set 'global.metrics.enableAgentMetrics=true' \
--set 'global.metrics.datadog.enabled=true' \
--set 'global.metrics.datadog.otlp.enabled=true' \
--set 'global.metrics.datadog.openMetricsPrometheus.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations' | tee /dev/stderr)

Expand Down Expand Up @@ -936,7 +936,7 @@ load _helpers

}

@test "server/StatefulSet: when datadog.otlp.enabled, applicable openmetrics annotation is set with tls url" {
@test "server/StatefulSet: when datadog.openMetricsPrometheus.enabled, applicable openmetrics annotation is set with tls url" {
cd `chart_dir`
local annotations=$(helm template \
-s templates/server-statefulset.yaml \
Expand All @@ -945,7 +945,7 @@ load _helpers
--set 'telemetryCollector.enabled=true' \
--set 'global.metrics.enableAgentMetrics=true' \
--set 'global.metrics.datadog.enabled=true' \
--set 'global.metrics.datadog.otlp.enabled=true' \
--set 'global.metrics.datadog.openMetricsPrometheus.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations' | tee /dev/stderr)

Expand Down Expand Up @@ -985,7 +985,7 @@ load _helpers
[ "${actual}" = ".*" ]
}

@test "server/StatefulSet: when global.metrics.datadog.otlp.enabled, applicable openmetrics annotation is set with acls.manageSystemACLs enabled" {
@test "server/StatefulSet: when global.metrics.datadog.openMetricsPrometheus.enabled, applicable openmetrics annotation is set with acls.manageSystemACLs enabled" {
cd `chart_dir`
local annotations=$(helm template \
-s templates/server-statefulset.yaml \
Expand All @@ -994,7 +994,7 @@ load _helpers
--set 'global.acls.manageSystemACLs=true' \
--set 'global.metrics.enableAgentMetrics=true' \
--set 'global.metrics.datadog.enabled=true' \
--set 'global.metrics.datadog.otlp.enabled=true' \
--set 'global.metrics.datadog.openMetricsPrometheus.enabled=true' \
. | tee /dev/stderr |
yq -r '.spec.template.metadata.annotations' | tee /dev/stderr)

Expand Down

0 comments on commit e4a234a

Please sign in to comment.