CSI configurable nodeSelector and affinity (#862)
This commit is contained in:
parent
a56c27c892
commit
3ce721fca4
6 changed files with 126 additions and 0 deletions
|
@ -4,6 +4,9 @@ Changes:
|
||||||
* Latest Kubernetes version tested is now 1.27
|
* Latest Kubernetes version tested is now 1.27
|
||||||
* server: Headless service ignores `server.service.publishNotReadyAddresses` setting and always sets it as `true` [GH-902](https://github.com/hashicorp/vault-helm/pull/902)
|
* server: Headless service ignores `server.service.publishNotReadyAddresses` setting and always sets it as `true` [GH-902](https://github.com/hashicorp/vault-helm/pull/902)
|
||||||
|
|
||||||
|
Features:
|
||||||
|
* CSI: Make `nodeSelector` and `affinity` configurable for CSI daemonset's pods [GH-862](https://github.com/hashicorp/vault-helm/pull/862)
|
||||||
|
|
||||||
Bugs:
|
Bugs:
|
||||||
* server: Set the default for `prometheusRules.rules` to an empty list [GH-886](https://github.com/hashicorp/vault-helm/pull/886)
|
* server: Set the default for `prometheusRules.rules` to an empty list [GH-886](https://github.com/hashicorp/vault-helm/pull/886)
|
||||||
|
|
||||||
|
|
|
@ -849,6 +849,34 @@ Sets the injector toleration for pod placement
|
||||||
{{- end }}
|
{{- end }}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
{{/*
|
||||||
|
Sets the CSI provider nodeSelector for pod placement
|
||||||
|
*/}}
|
||||||
|
{{- define "csi.pod.nodeselector" -}}
|
||||||
|
{{- if .Values.csi.pod.nodeSelector }}
|
||||||
|
nodeSelector:
|
||||||
|
{{- $tp := typeOf .Values.csi.pod.nodeSelector }}
|
||||||
|
{{- if eq $tp "string" }}
|
||||||
|
{{ tpl .Values.csi.pod.nodeSelector . | nindent 8 | trim }}
|
||||||
|
{{- else }}
|
||||||
|
{{- toYaml .Values.csi.pod.nodeSelector | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end }}
|
||||||
|
{{- end -}}
|
||||||
|
{{/*
|
||||||
|
Sets the CSI provider affinity for pod placement.
|
||||||
|
*/}}
|
||||||
|
{{- define "csi.pod.affinity" -}}
|
||||||
|
{{- if .Values.csi.pod.affinity }}
|
||||||
|
affinity:
|
||||||
|
{{ $tp := typeOf .Values.csi.pod.affinity }}
|
||||||
|
{{- if eq $tp "string" }}
|
||||||
|
{{- tpl .Values.csi.pod.affinity . | nindent 8 | trim }}
|
||||||
|
{{- else }}
|
||||||
|
{{- toYaml .Values.csi.pod.affinity | nindent 8 }}
|
||||||
|
{{- end }}
|
||||||
|
{{ end }}
|
||||||
|
{{- end -}}
|
||||||
{{/*
|
{{/*
|
||||||
Sets extra CSI provider pod annotations
|
Sets extra CSI provider pod annotations
|
||||||
*/}}
|
*/}}
|
||||||
|
|
|
@ -45,6 +45,8 @@ spec:
|
||||||
{{- end }}
|
{{- end }}
|
||||||
serviceAccountName: {{ template "vault.fullname" . }}-csi-provider
|
serviceAccountName: {{ template "vault.fullname" . }}-csi-provider
|
||||||
{{- template "csi.pod.tolerations" . }}
|
{{- template "csi.pod.tolerations" . }}
|
||||||
|
{{- template "csi.pod.nodeselector" . }}
|
||||||
|
{{- template "csi.pod.affinity" . }}
|
||||||
containers:
|
containers:
|
||||||
- name: {{ include "vault.name" . }}-csi-provider
|
- name: {{ include "vault.name" . }}-csi-provider
|
||||||
{{ template "csi.resources" . }}
|
{{ template "csi.resources" . }}
|
||||||
|
|
|
@ -345,6 +345,74 @@ load _helpers
|
||||||
[ "${actual}" = "true" ]
|
[ "${actual}" = "true" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# nodeSelector
|
||||||
|
@test "csi/daemonset: nodeSelector not set by default" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/csi-daemonset.yaml \
|
||||||
|
--set 'csi.enabled=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.template.spec | .nodeSelector? == null' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "csi/daemonset: nodeSelector can be set as string" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/csi-daemonset.yaml \
|
||||||
|
--set 'csi.enabled=true' \
|
||||||
|
--set 'csi.pod.nodeSelector=foobar' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.template.spec.nodeSelector == "foobar"' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "csi/daemonset: nodeSelector can be set as YAML" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/csi-daemonset.yaml \
|
||||||
|
--set 'csi.enabled=true' \
|
||||||
|
--set "csi.pod.nodeSelector[0].foo=bar,csi.pod.nodeSelector[1].baz=qux" \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.template.spec.nodeSelector[0].foo == "bar" and .spec.template.spec.nodeSelector[1].baz == "qux"' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
#--------------------------------------------------------------------
|
||||||
|
# affinity
|
||||||
|
@test "csi/daemonset: affinity not set by default" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/csi-daemonset.yaml \
|
||||||
|
--set 'csi.enabled=true' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.template.spec | .affinity? == null' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "csi/daemonset: affinity can be set as string" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/csi-daemonset.yaml \
|
||||||
|
--set 'csi.enabled=true' \
|
||||||
|
--set 'csi.pod.affinity=foobar' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.template.spec.affinity == "foobar"' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "csi/daemonset: affinity can be set as YAML" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
--show-only templates/csi-daemonset.yaml \
|
||||||
|
--set 'csi.enabled=true' \
|
||||||
|
--set "csi.pod.affinity.podAntiAffinity=foobar" \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.template.spec.affinity.podAntiAffinity == "foobar"' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "true" ]
|
||||||
|
}
|
||||||
|
|
||||||
#--------------------------------------------------------------------
|
#--------------------------------------------------------------------
|
||||||
# Extra Labels
|
# Extra Labels
|
||||||
|
|
||||||
|
|
|
@ -136,6 +136,13 @@
|
||||||
"pod": {
|
"pod": {
|
||||||
"type": "object",
|
"type": "object",
|
||||||
"properties": {
|
"properties": {
|
||||||
|
"affinity": {
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"array",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
|
},
|
||||||
"annotations": {
|
"annotations": {
|
||||||
"type": [
|
"type": [
|
||||||
"object",
|
"object",
|
||||||
|
@ -145,6 +152,13 @@
|
||||||
"extraLabels": {
|
"extraLabels": {
|
||||||
"type": "object"
|
"type": "object"
|
||||||
},
|
},
|
||||||
|
"nodeSelector": {
|
||||||
|
"type": [
|
||||||
|
"null",
|
||||||
|
"array",
|
||||||
|
"string"
|
||||||
|
]
|
||||||
|
},
|
||||||
"tolerations": {
|
"tolerations": {
|
||||||
"type": [
|
"type": [
|
||||||
"null",
|
"null",
|
||||||
|
|
11
values.yaml
11
values.yaml
|
@ -1065,6 +1065,17 @@ csi:
|
||||||
# in a PodSpec.
|
# in a PodSpec.
|
||||||
tolerations: []
|
tolerations: []
|
||||||
|
|
||||||
|
# nodeSelector labels for csi pod assignment, formatted as a multi-line string or YAML map.
|
||||||
|
# ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#nodeselector
|
||||||
|
# Example:
|
||||||
|
# nodeSelector:
|
||||||
|
# beta.kubernetes.io/arch: amd64
|
||||||
|
nodeSelector: []
|
||||||
|
|
||||||
|
# Affinity Settings
|
||||||
|
# This should be either a multi-line string or YAML matching the PodSpec's affinity field.
|
||||||
|
affinity: {}
|
||||||
|
|
||||||
# Extra labels to attach to the vault-csi-provider pod
|
# 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
|
# This should be a YAML map of the labels to apply to the csi provider pod
|
||||||
extraLabels: {}
|
extraLabels: {}
|
||||||
|
|
Loading…
Reference in a new issue