From c65adfb0b741fdb888576e46c22c64644c97463b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?L=C3=A9na=C3=AFc=20Huard?= Date: Mon, 16 Dec 2019 18:27:37 +0100 Subject: [PATCH] [stable/datadog] Allow dots in cluster names (#19618) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * [stable/datadog] Allow dots in cluster names because some users already have dots in their cluster names: https://github.com/helm/charts/pull/19327#issuecomment-565535449 Signed-off-by: Lénaïc Huard * [stable/datadog] Add a test for clusterName Signed-off-by: Lénaïc Huard --- stable/datadog/Chart.yaml | 2 +- stable/datadog/ci/cluster-name.yaml | 4 ++++ stable/datadog/templates/cluster-agent-deployment.yaml | 4 ++-- stable/datadog/templates/container-agent.yaml | 4 ++-- stable/datadog/templates/container-agents.yaml | 4 ++-- stable/datadog/values.yaml | 4 ++-- 6 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 stable/datadog/ci/cluster-name.yaml diff --git a/stable/datadog/Chart.yaml b/stable/datadog/Chart.yaml index bf3c64250c..a57289eb45 100644 --- a/stable/datadog/Chart.yaml +++ b/stable/datadog/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v1 name: datadog -version: 1.38.12 +version: 1.38.13 appVersion: "6" description: DataDog Agent keywords: diff --git a/stable/datadog/ci/cluster-name.yaml b/stable/datadog/ci/cluster-name.yaml new file mode 100644 index 0000000000..812dd0f12f --- /dev/null +++ b/stable/datadog/ci/cluster-name.yaml @@ -0,0 +1,4 @@ +# Empty values file for testing default parameters. + +datadog: + clusterName: kubernetes-cluster.example.com diff --git a/stable/datadog/templates/cluster-agent-deployment.yaml b/stable/datadog/templates/cluster-agent-deployment.yaml index a39a789c4a..59ad454819 100644 --- a/stable/datadog/templates/cluster-agent-deployment.yaml +++ b/stable/datadog/templates/cluster-agent-deployment.yaml @@ -101,8 +101,8 @@ spec: value: "kube_services" {{- end }} {{- if .Values.datadog.clusterName }} - {{- if not (regexMatch "^[a-z]([a-z0-9\\-]{0,38}[a-z0-9])?$" .Values.datadog.clusterName) }} - {{- fail "Your `clusterName` isn’t valid. It must start with a lowercase letter followed by up to 39 lowercase letters, numbers, or hyphens and cannot end with a hyphen."}} + {{- 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 }} diff --git a/stable/datadog/templates/container-agent.yaml b/stable/datadog/templates/container-agent.yaml index 516e535246..2c85b3f6f9 100644 --- a/stable/datadog/templates/container-agent.yaml +++ b/stable/datadog/templates/container-agent.yaml @@ -15,8 +15,8 @@ env: {{- include "containers-common-env" . | nindent 4 }} {{- if .Values.datadog.clusterName }} - {{- if not (regexMatch "^[a-z]([a-z0-9\\-]{0,38}[a-z0-9])?$" .Values.datadog.clusterName) }} - {{- fail "Your `clusterName` isn’t valid. It must start with a lowercase letter followed by up to 39 lowercase letters, numbers, or hyphens and cannot end with a hyphen."}} + {{- 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 }} diff --git a/stable/datadog/templates/container-agents.yaml b/stable/datadog/templates/container-agents.yaml index 845176163a..fa00d4411a 100644 --- a/stable/datadog/templates/container-agents.yaml +++ b/stable/datadog/templates/container-agents.yaml @@ -26,8 +26,8 @@ name: {{ template "datadog.apiSecretName" . }} key: api-key {{- if .Values.datadog.clusterName }} - {{- if not (regexMatch "^[a-z]([a-z0-9\\-]{0,38}[a-z0-9])?$" .Values.datadog.clusterName) }} - {{- fail "Your `clusterName` isn’t valid. It must start with a lowercase letter followed by up to 39 lowercase letters, numbers, or hyphens and cannot end with a hyphen."}} + {{- 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 }} diff --git a/stable/datadog/values.yaml b/stable/datadog/values.yaml index 2e60735444..7501290a23 100644 --- a/stable/datadog/values.yaml +++ b/stable/datadog/values.yaml @@ -71,11 +71,11 @@ datadog: ## @param clusterName - string - optional ## Set a unique cluster name to allow scoping hosts and Cluster Checks easily - ## The name must be unique and can be up to 40 characters with the following restrictions: + ## The name must be unique and must be dot-separated tokens where a token can be up to 40 characters with the following restrictions: ## * Lowercase letters, numbers, and hyphens only. ## * Must start with a letter. ## * Must end with a number or a letter. - ## These are the same rules as the one enforced by GKE on the same cluster name parameter: + ## Compared to the rules of GKE, dots are allowed whereas they are not allowed on GKE: ## https://cloud.google.com/kubernetes-engine/docs/reference/rest/v1beta1/projects.locations.clusters#Cluster.FIELDS.name # # clusterName: