From c5927a8bbce4b692e9cfd177ff84153139d3ca29 Mon Sep 17 00:00:00 2001 From: Michael Schuett Date: Wed, 23 Feb 2022 15:45:21 -0600 Subject: [PATCH 1/3] Add extraLabels for CSI DaemonSet --- templates/csi-daemonset.yaml | 3 +++ values.schema.json | 3 +++ values.yaml | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/templates/csi-daemonset.yaml b/templates/csi-daemonset.yaml index f0bf639f3..9a2a41afd 100644 --- a/templates/csi-daemonset.yaml +++ b/templates/csi-daemonset.yaml @@ -8,6 +8,9 @@ metadata: app.kubernetes.io/name: {{ include "vault.name" . }}-csi-provider app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- if .Values.csi.extraLabels -}} + {{- toYaml .Values.csi.extraLabels | nindent 8 -}} + {{- end -}} {{ template "csi.daemonSet.annotations" . }} spec: updateStrategy: diff --git a/values.schema.json b/values.schema.json index 15440431a..1feb0803b 100644 --- a/values.schema.json +++ b/values.schema.json @@ -45,6 +45,9 @@ "extraArgs": { "type": "array" }, + "extraLabels": { + "type": "object" + }, "image": { "type": "object", "properties": { diff --git a/values.yaml b/values.yaml index 61af7b2dd..9be39fba1 100644 --- a/values.yaml +++ b/values.yaml @@ -854,5 +854,9 @@ csi: # Enables debug logging. debug: false + # Extra labels to attach to the vault-csi-provider + # This should be a YAML map of the labels to apply to the csi provider + extraLabels: {} + # Pass arbitrary additional arguments to vault-csi-provider. extraArgs: [] From 200dbdd7f3c80519f0375db6280b18760b18a5eb Mon Sep 17 00:00:00 2001 From: Michael Schuett Date: Wed, 23 Feb 2022 15:51:10 -0600 Subject: [PATCH 2/3] Move labels to the correct location --- templates/csi-daemonset.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/csi-daemonset.yaml b/templates/csi-daemonset.yaml index 9a2a41afd..9895944ba 100644 --- a/templates/csi-daemonset.yaml +++ b/templates/csi-daemonset.yaml @@ -8,9 +8,6 @@ metadata: app.kubernetes.io/name: {{ include "vault.name" . }}-csi-provider app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} - {{- if .Values.csi.extraLabels -}} - {{- toYaml .Values.csi.extraLabels | nindent 8 -}} - {{- end -}} {{ template "csi.daemonSet.annotations" . }} spec: updateStrategy: @@ -28,6 +25,9 @@ spec: labels: app.kubernetes.io/name: {{ template "vault.name" . }}-csi-provider app.kubernetes.io/instance: {{ .Release.Name }} + {{- if .Values.csi.extraLabels -}} + {{- toYaml .Values.csi.extraLabels | nindent 8 -}} + {{- end -}} {{ template "csi.pod.annotations" . }} spec: {{- if .Values.csi.priorityClassName }} From de6e7322dd41cd44520150c84e16a736fd36ad97 Mon Sep 17 00:00:00 2001 From: Michael Schuett Date: Thu, 24 Feb 2022 17:07:43 -0600 Subject: [PATCH 3/3] Refactor per comments --- templates/csi-daemonset.yaml | 7 +++++-- templates/csi-serviceaccount.yaml | 3 +++ test/unit/csi-daemonset.bats | 26 ++++++++++++++++++++++++++ test/unit/csi-serviceaccount.bats | 17 ++++++++++++++++- values.schema.json | 12 +++++++++--- values.yaml | 17 +++++++++++++---- 6 files changed, 72 insertions(+), 10 deletions(-) diff --git a/templates/csi-daemonset.yaml b/templates/csi-daemonset.yaml index 9895944ba..430889061 100644 --- a/templates/csi-daemonset.yaml +++ b/templates/csi-daemonset.yaml @@ -8,6 +8,9 @@ metadata: app.kubernetes.io/name: {{ include "vault.name" . }}-csi-provider app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- if .Values.csi.daemonSet.extraLabels -}} + {{- toYaml .Values.csi.daemonSet.extraLabels | nindent 4 -}} + {{- end -}} {{ template "csi.daemonSet.annotations" . }} spec: updateStrategy: @@ -25,8 +28,8 @@ spec: labels: app.kubernetes.io/name: {{ template "vault.name" . }}-csi-provider app.kubernetes.io/instance: {{ .Release.Name }} - {{- if .Values.csi.extraLabels -}} - {{- toYaml .Values.csi.extraLabels | nindent 8 -}} + {{- if .Values.csi.pod.extraLabels -}} + {{- toYaml .Values.csi.pod.extraLabels | nindent 8 -}} {{- end -}} {{ template "csi.pod.annotations" . }} spec: diff --git a/templates/csi-serviceaccount.yaml b/templates/csi-serviceaccount.yaml index ee127481b..eb9a78404 100644 --- a/templates/csi-serviceaccount.yaml +++ b/templates/csi-serviceaccount.yaml @@ -8,5 +8,8 @@ metadata: app.kubernetes.io/name: {{ include "vault.name" . }}-csi-provider app.kubernetes.io/instance: {{ .Release.Name }} app.kubernetes.io/managed-by: {{ .Release.Service }} + {{- if .Values.csi.serviceAccount.extraLabels -}} + {{- toYaml .Values.csi.serviceAccount.extraLabels | nindent 4 -}} + {{- end -}} {{ template "csi.serviceAccount.annotations" . }} {{- end }} diff --git a/test/unit/csi-daemonset.bats b/test/unit/csi-daemonset.bats index dd88d829a..ed8864352 100644 --- a/test/unit/csi-daemonset.bats +++ b/test/unit/csi-daemonset.bats @@ -318,6 +318,32 @@ load _helpers [ "${actual}" = "true" ] } +#-------------------------------------------------------------------- +# Extra Labels + +@test "csi/daemonset: specify csi.daemonSet.extraLabels" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + --set 'csi.daemonSet.extraLabels.foo=bar' \ + . | tee /dev/stderr | + yq -r '.metadata.labels.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + +@test "csi/daemonset: specify csi.pod.extraLabels" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/csi-daemonset.yaml \ + --set 'csi.enabled=true' \ + --set 'csi.pod.extraLabels.foo=bar' \ + . | tee /dev/stderr | + yq -r '.spec.template.metadata.labels.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + + #-------------------------------------------------------------------- # volumes diff --git a/test/unit/csi-serviceaccount.bats b/test/unit/csi-serviceaccount.bats index 22ba06df2..0d61bc3aa 100644 --- a/test/unit/csi-serviceaccount.bats +++ b/test/unit/csi-serviceaccount.bats @@ -56,4 +56,19 @@ load _helpers . | tee /dev/stderr | yq -r '.metadata.annotations["foo"]' | tee /dev/stderr) [ "${actual}" = "bar" ] -} \ No newline at end of file +} + +# serviceAccount extraLabels + +@test "csi/serviceAccount: specify csi.serviceAccount.extraLabels" { + cd `chart_dir` + local actual=$(helm template \ + --show-only templates/csi-serviceaccount.yaml \ + --set 'csi.enabled=true' \ + --set 'csi.serviceAccount.extraLabels.foo=bar' \ + . | tee /dev/stderr | + yq -r '.metadata.labels.foo' | tee /dev/stderr) + [ "${actual}" = "bar" ] +} + + diff --git a/values.schema.json b/values.schema.json index 1feb0803b..b42e15218 100644 --- a/values.schema.json +++ b/values.schema.json @@ -14,6 +14,9 @@ "string" ] }, + "extraLabels": { + "type": "object" + }, "kubeletRootDir": { "type": "string" }, @@ -45,9 +48,6 @@ "extraArgs": { "type": "array" }, - "extraLabels": { - "type": "object" - }, "image": { "type": "object", "properties": { @@ -91,6 +91,9 @@ "string" ] }, + "extraLabels": { + "type": "object" + }, "tolerations": { "type": [ "null", @@ -131,6 +134,9 @@ "object", "string" ] + }, + "extraLabels": { + "type": "object" } } }, diff --git a/values.yaml b/values.yaml index 9be39fba1..22f97bb72 100644 --- a/values.yaml +++ b/values.yaml @@ -805,6 +805,9 @@ csi: providersDir: "/etc/kubernetes/secrets-store-csi-providers" # Kubelet host path kubeletRootDir: "/var/lib/kubelet" + # Extra labels to attach to the vault-csi-provider daemonSet + # This should be a YAML map of the labels to apply to the csi provider daemonSet + extraLabels: {} pod: # Extra annotations for the provider pods. This can either be YAML or a @@ -817,6 +820,12 @@ csi: # in a PodSpec. tolerations: [] + # Extra labels to attach to the vault-csi-provider pod + # This should be a YAML map of the labels to apply to the csi provider pod + extraLabels: {} + + + # Priority class for csi pods priorityClassName: "" @@ -826,6 +835,10 @@ csi: # annotations to apply to the serviceAccount. annotations: {} + # Extra labels to attach to the vault-csi-provider serviceAccount + # This should be a YAML map of the labels to apply to the csi provider serviceAccount + extraLabels: {} + # Used to configure readinessProbe for the pods. readinessProbe: # When a probe fails, Kubernetes will try failureThreshold times before giving up @@ -854,9 +867,5 @@ csi: # Enables debug logging. debug: false - # Extra labels to attach to the vault-csi-provider - # This should be a YAML map of the labels to apply to the csi provider - extraLabels: {} - # Pass arbitrary additional arguments to vault-csi-provider. extraArgs: []