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

Helm: Support minAvailable on connect injector PDB #1557

Merged
merged 2 commits into from Oct 14, 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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -17,7 +17,11 @@ metadata:
release: {{ .Release.Name }}
component: connect-injector
spec:
{{- if .Values.connectInject.disruptionBudget.minAvailable }}
minAvailable: {{ .Values.connectInject.disruptionBudget.minAvailable }}
{{- else }}
maxUnavailable: {{ template "consul.pdb.connectInject.maxUnavailable" . }}
{{- end }}
selector:
matchLabels:
app: {{ template "consul.name" . }}
Expand Down
32 changes: 32 additions & 0 deletions charts/consul/test/unit/connect-injector-disruptionbudget.bats
Expand Up @@ -159,3 +159,35 @@ load _helpers
# no flag to *remove* an API version so some Helm versions will always have
# policy/v1 support and will always use that API version.


#--------------------------------------------------------------------
# minAvailable

@test "connect-injector/DisruptionBudget: correct minAvailable when set" {
cd `chart_dir`
local tpl=$(helm template \
-s templates/connect-injector-disruptionbudget.yaml \
--set 'connectInject.replicas=1' \
--set 'global.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'connectInject.disruptionBudget.enabled=true' \
--set 'connectInject.disruptionBudget.minAvailable=1' \
. | tee /dev/stderr)
[ $(echo "$tpl" | yq '.spec.minAvailable') = "1" ]
[ $(echo "$tpl" | yq '.spec.maxUnavailable') = "null" ]
}

@test "connect-injector/DisruptionBudget: correct minAvailable when set with maxUnavailable" {
cd `chart_dir`
local tpl=$(helm template \
-s templates/connect-injector-disruptionbudget.yaml \
--set 'connectInject.replicas=1' \
--set 'global.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'connectInject.disruptionBudget.enabled=true' \
--set 'connectInject.disruptionBudget.minAvailable=1' \
--set 'connectInject.disruptionBudget.maxUnavailable=2' \
. | tee /dev/stderr)
[ $(echo "$tpl" | yq '.spec.minAvailable') = "1" ]
[ $(echo "$tpl" | yq '.spec.maxUnavailable') = "null" ]
}
5 changes: 5 additions & 0 deletions charts/consul/values.yaml
Expand Up @@ -1937,6 +1937,11 @@ connectInject:
# @type: integer
maxUnavailable: null

# The minimum number of available pods.
# Takes precedence over maxUnavailable if set.
# @type: integer
minAvailable: null

# Configures consul-cni plugin for Consul Service mesh services
cni:
# If true, then all traffic redirection setup will use the consul-cni plugin.
Expand Down