Fix PodDisruptionBudget template (#88)
* Fix bad selectors. * Fix bad calculation of maxUnavailable. Signed-off-by: JrCs <90z7oey02@sneakemail.com>
This commit is contained in:
parent
b41d36c621
commit
75ceb1af5a
3 changed files with 26 additions and 4 deletions
|
@ -42,7 +42,7 @@ Add a special case for replicas=1, where it should default to 0 as well.
|
||||||
{{- else if .Values.server.ha.disruptionBudget.maxUnavailable -}}
|
{{- else if .Values.server.ha.disruptionBudget.maxUnavailable -}}
|
||||||
{{ .Values.server.ha.disruptionBudget.maxUnavailable -}}
|
{{ .Values.server.ha.disruptionBudget.maxUnavailable -}}
|
||||||
{{- else -}}
|
{{- else -}}
|
||||||
{{- ceil (sub (div (int .Values.server.ha.replicas) 2) 1) -}}
|
{{- div (sub (div (mul (int .Values.server.ha.replicas) 10) 2) 1) 10 -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
||||||
|
|
|
@ -16,7 +16,7 @@ spec:
|
||||||
maxUnavailable: {{ template "vault.pdb.maxUnavailable" . }}
|
maxUnavailable: {{ template "vault.pdb.maxUnavailable" . }}
|
||||||
selector:
|
selector:
|
||||||
matchLabels:
|
matchLabels:
|
||||||
app: {{ template "vault.name" . }}
|
app.kubernetes.io/name: {{ include "vault.name" . }}
|
||||||
release: "{{ .Release.Name }}"
|
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||||
component: server
|
component: server
|
||||||
{{- end -}}
|
{{- end -}}
|
||||||
|
|
|
@ -43,6 +43,17 @@ load _helpers
|
||||||
[ "${actual}" = "false" ]
|
[ "${actual}" = "false" ]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: correct maxUnavailable with n=1" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'server.ha.replicas=1' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.maxUnavailable' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "0" ]
|
||||||
|
}
|
||||||
|
|
||||||
@test "server/DisruptionBudget: correct maxUnavailable with n=3" {
|
@test "server/DisruptionBudget: correct maxUnavailable with n=3" {
|
||||||
cd `chart_dir`
|
cd `chart_dir`
|
||||||
local actual=$(helm template \
|
local actual=$(helm template \
|
||||||
|
@ -51,5 +62,16 @@ load _helpers
|
||||||
--set 'server.ha.replicas=3' \
|
--set 'server.ha.replicas=3' \
|
||||||
. | tee /dev/stderr |
|
. | tee /dev/stderr |
|
||||||
yq '.spec.maxUnavailable' | tee /dev/stderr)
|
yq '.spec.maxUnavailable' | tee /dev/stderr)
|
||||||
[ "${actual}" = "0" ]
|
[ "${actual}" = "1" ]
|
||||||
|
}
|
||||||
|
|
||||||
|
@test "server/DisruptionBudget: correct maxUnavailable with n=5" {
|
||||||
|
cd `chart_dir`
|
||||||
|
local actual=$(helm template \
|
||||||
|
-x templates/server-disruptionbudget.yaml \
|
||||||
|
--set 'server.ha.enabled=true' \
|
||||||
|
--set 'server.ha.replicas=5' \
|
||||||
|
. | tee /dev/stderr |
|
||||||
|
yq '.spec.maxUnavailable' | tee /dev/stderr)
|
||||||
|
[ "${actual}" = "2" ]
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue