Skip to content

Commit

Permalink
Add extraLabels for CSI DaemonSet (hashicorp#690)
Browse files Browse the repository at this point in the history
  • Loading branch information
michaeljs1990 authored and illegalnumbers committed Mar 16, 2022
1 parent 7767d33 commit 141fad2
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 1 deletion.
6 changes: 6 additions & 0 deletions templates/csi-daemonset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -25,6 +28,9 @@ spec:
labels:
app.kubernetes.io/name: {{ template "vault.name" . }}-csi-provider
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.csi.pod.extraLabels -}}
{{- toYaml .Values.csi.pod.extraLabels | nindent 8 -}}
{{- end -}}
{{ template "csi.pod.annotations" . }}
spec:
{{- if .Values.csi.priorityClassName }}
Expand Down
3 changes: 3 additions & 0 deletions templates/csi-serviceaccount.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
26 changes: 26 additions & 0 deletions test/unit/csi-daemonset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 16 additions & 1 deletion test/unit/csi-serviceaccount.bats
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,19 @@ load _helpers
. | tee /dev/stderr |
yq -r '.metadata.annotations["foo"]' | tee /dev/stderr)
[ "${actual}" = "bar" ]
}
}

# 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" ]
}


9 changes: 9 additions & 0 deletions values.schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@
"string"
]
},
"extraLabels": {
"type": "object"
},
"kubeletRootDir": {
"type": "string"
},
Expand Down Expand Up @@ -88,6 +91,9 @@
"string"
]
},
"extraLabels": {
"type": "object"
},
"tolerations": {
"type": [
"null",
Expand Down Expand Up @@ -128,6 +134,9 @@
"object",
"string"
]
},
"extraLabels": {
"type": "object"
}
}
},
Expand Down
13 changes: 13 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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: ""

Expand All @@ -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
Expand Down

0 comments on commit 141fad2

Please sign in to comment.