Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add extraLabels for CSI DaemonSet #690

Merged
merged 3 commits into from
Feb 25, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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