Skip to content

Commit

Permalink
Allow scale to zero (#943)
Browse files Browse the repository at this point in the history
  • Loading branch information
therealjsie authored Aug 15, 2023
1 parent 9a16496 commit ec964a3
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
6 changes: 5 additions & 1 deletion templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,11 @@ Set's the replica count based on the different modes configured by user
{{ if eq .mode "standalone" }}
{{- default 1 -}}
{{ else if eq .mode "ha" }}
{{- .Values.server.ha.replicas | default 3 -}}
{{- if kindIs "int64" .Values.server.ha.replicas -}}
{{- .Values.server.ha.replicas -}}
{{ else }}
{{- 3 -}}
{{- end -}}
{{ else }}
{{- default 1 -}}
{{ end }}
Expand Down
22 changes: 22 additions & 0 deletions test/unit/server-ha-statefulset.bats
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,28 @@ load _helpers
[ "${actual}" = "10" ]
}

@test "server/ha-StatefulSet: zero replicas" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.ha.enabled=true' \
--set 'server.ha.replicas=0' \
. | tee /dev/stderr |
yq -r '.spec.replicas' | tee /dev/stderr)
[ "${actual}" = "0" ]
}

@test "server/ha-StatefulSet: invalid value for replicas" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-statefulset.yaml \
--set 'server.ha.enabled=true' \
--set 'server.ha.replicas=null' \
. | tee /dev/stderr |
yq -r '.spec.replicas' | tee /dev/stderr)
[ "${actual}" = "3" ]
}

#--------------------------------------------------------------------
# resources

Expand Down

0 comments on commit ec964a3

Please # to comment.