Compare commits

...

10 commits

Author SHA1 Message Date
Christopher Swenson
4c752a9f1d
Merge branch 'main' into topology 2022-04-28 10:26:20 -07:00
Eric Miller
fb3126b864 Allow topologySpreadConstraints to be a string 2021-11-30 15:49:12 -06:00
Eric Miller
b67a874090 Merge branch 'main' into topology 2021-11-22 15:29:50 -06:00
Eric Miller
102c29955b Implement injector HA statefulset topology UTs 2021-11-22 15:24:38 -06:00
Eric Miller
567a4386a5 Implement injector statefulset topology spread UTs 2021-11-22 15:21:15 -06:00
Eric Miller
f49ecb6802 Implement injector deployment topology spread UTs
* also remove string from the relevant schema types
2021-11-22 15:12:17 -06:00
Eric Miller
8840187301 Add topologySpreadConstraints to values schema 2021-11-22 14:36:11 -06:00
Ellis Tarn
87c3e62030
Update values.yaml
Co-authored-by: Ben Ash <32777270+benashz@users.noreply.github.com>
2021-09-27 15:19:47 -07:00
Ellis Tarn
c77cb1f6a4
Update values.yaml
Co-authored-by: Ben Ash <32777270+benashz@users.noreply.github.com>
2021-09-27 15:19:43 -07:00
Ellis Tarn
18f8db05d9 Implemented support for topology spread constraints 2021-09-17 16:30:49 -07:00
8 changed files with 122 additions and 0 deletions

View file

@ -293,6 +293,37 @@ Sets the injector affinity for pod placement
{{ end }} {{ end }}
{{- end -}} {{- end -}}
{{/*
Sets the topologySpreadConstraints when running in standalone and HA modes.
*/}}
{{- define "vault.topologySpreadConstraints" -}}
{{- if and (ne .mode "dev") .Values.server.topologySpreadConstraints }}
topologySpreadConstraints:
{{ $tp := typeOf .Values.server.topologySpreadConstraints }}
{{- if eq $tp "string" }}
{{- tpl .Values.server.topologySpreadConstraints . | nindent 8 | trim }}
{{- else }}
{{- toYaml .Values.server.topologySpreadConstraints | nindent 8 }}
{{- end }}
{{ end }}
{{- end -}}
{{/*
Sets the injector topologySpreadConstraints for pod placement
*/}}
{{- define "injector.topologySpreadConstraints" -}}
{{- if .Values.injector.topologySpreadConstraints }}
topologySpreadConstraints:
{{ $tp := typeOf .Values.injector.topologySpreadConstraints }}
{{- if eq $tp "string" }}
{{- tpl .Values.injector.topologySpreadConstraints . | nindent 8 | trim }}
{{- else }}
{{- toYaml .Values.injector.topologySpreadConstraints | nindent 8 }}
{{- end }}
{{ end }}
{{- end -}}
{{/* {{/*
Sets the toleration for pod placement when running in standalone and HA modes. Sets the toleration for pod placement when running in standalone and HA modes.
*/}} */}}

View file

@ -31,6 +31,7 @@ spec:
{{ template "injector.annotations" . }} {{ template "injector.annotations" . }}
spec: spec:
{{ template "injector.affinity" . }} {{ template "injector.affinity" . }}
{{ template "injector.topologySpreadConstraints" . }}
{{ template "injector.tolerations" . }} {{ template "injector.tolerations" . }}
{{ template "injector.nodeselector" . }} {{ template "injector.nodeselector" . }}
{{- if .Values.injector.priorityClassName }} {{- if .Values.injector.priorityClassName }}

View file

@ -37,6 +37,7 @@ spec:
{{ template "vault.annotations" . }} {{ template "vault.annotations" . }}
spec: spec:
{{ template "vault.affinity" . }} {{ template "vault.affinity" . }}
{{ template "vault.topologySpreadConstraints" . }}
{{ template "vault.tolerations" . }} {{ template "vault.tolerations" . }}
{{ template "vault.nodeselector" . }} {{ template "vault.nodeselector" . }}
{{- if .Values.server.priorityClassName }} {{- if .Values.server.priorityClassName }}

View file

@ -462,6 +462,27 @@ load _helpers
[ "${actual}" = "true" ] [ "${actual}" = "true" ]
} }
#--------------------------------------------------------------------
# topologySpreadConstraints
@test "injector/deployment: topologySpreadConstraints is null by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-deployment.yaml \
. | tee /dev/stderr |
yq '.spec.template.spec | .topologySpreadConstraints? == null' | tee /dev/stderr)
}
@test "injector/deployment: topologySpreadConstraints can be set as YAML" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-deployment.yaml \
--set "injector.topologySpreadConstraints[0].foo=bar,injector.topologySpreadConstraints[1].baz=qux" \
. | tee /dev/stderr |
yq '.spec.template.spec.topologySpreadConstraints == [{"foo": "bar"}, {"baz": "qux"}]' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
#-------------------------------------------------------------------- #--------------------------------------------------------------------
# tolerations # tolerations

View file

@ -585,6 +585,32 @@ load _helpers
[ "${actual}" = "1" ] [ "${actual}" = "1" ]
} }
#--------------------------------------------------------------------
# topologySpreadConstraints
@test "server/ha-StatefulSet: topologySpreadConstraints is null by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.ha.enabled=true' \
. | tee /dev/stderr |
yq '.spec.template.spec | .topologySpreadConstraints? == null' | tee /dev/stderr)
}
@test "server/ha-StatefulSet: topologySpreadConstraints can be set as YAML" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.ha.enabled=true' \
--set "server.topologySpreadConstraints[0].foo=bar,server.topologySpreadConstraints[1].baz=qux" \
. | tee /dev/stderr |
yq '.spec.template.spec.topologySpreadConstraints == [{"foo": "bar"}, {"baz": "qux"}]' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
#--------------------------------------------------------------------
# tolerations
@test "server/ha-StatefulSet: tolerations not set by default" { @test "server/ha-StatefulSet: tolerations not set by default" {
cd `chart_dir` cd `chart_dir`
local actual=$(helm template \ local actual=$(helm template \

View file

@ -784,6 +784,29 @@ load _helpers
[ "${actual}" = "true" ] [ "${actual}" = "true" ]
} }
#--------------------------------------------------------------------
# topologySpreadConstraints
@test "server/standalone-StatefulSet: topologySpreadConstraints is null by default" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
. | tee /dev/stderr |
yq '.spec.template.spec | .topologySpreadConstraints? == null' | tee /dev/stderr)
}
@test "server/standalone-StatefulSet: topologySpreadConstraints can be set as YAML" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set "server.topologySpreadConstraints[0].foo=bar,server.topologySpreadConstraints[1].baz=qux" \
. | tee /dev/stderr |
yq '.spec.template.spec.topologySpreadConstraints == [{"foo": "bar"}, {"baz": "qux"}]' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
#--------------------------------------------------------------------
# tolerations
@test "server/standalone-StatefulSet: tolerations not set by default" { @test "server/standalone-StatefulSet: tolerations not set by default" {
cd `chart_dir` cd `chart_dir`

View file

@ -380,6 +380,13 @@
"string" "string"
] ]
}, },
"topologySpreadConstraints": {
"type": [
"null",
"array",
"string"
]
},
"webhook": { "webhook": {
"type": "object", "type": "object",
"properties": { "properties": {

View file

@ -218,6 +218,12 @@ injector:
component: webhook component: webhook
topologyKey: kubernetes.io/hostname topologyKey: kubernetes.io/hostname
# Topology settings for injector pods
# ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
# This should be either a multi-line string or YAML matching the topologySpreadConstraints array
# in a PodSpec.
topologySpreadConstraints: []
# Toleration Settings for injector pods # Toleration Settings for injector pods
# This should be either a multi-line string or YAML matching the Toleration array # This should be either a multi-line string or YAML matching the Toleration array
# in a PodSpec. # in a PodSpec.
@ -508,6 +514,12 @@ server:
component: server component: server
topologyKey: kubernetes.io/hostname topologyKey: kubernetes.io/hostname
# Topology settings for server pods
# ref: https://kubernetes.io/docs/concepts/workloads/pods/pod-topology-spread-constraints/
# This should be either a multi-line string or YAML matching the topologySpreadConstraints array
# in a PodSpec.
topologySpreadConstraints: []
# Toleration Settings for server pods # Toleration Settings for server pods
# This should be either a multi-line string or YAML matching the Toleration array # This should be either a multi-line string or YAML matching the Toleration array
# in a PodSpec. # in a PodSpec.