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

Issue #667, adding updates to the disruptionbudget to support new non… #710

Merged
merged 3 commits into from
Apr 5, 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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ CHANGES:
Improvements:
* CSI: Set `extraLabels` for daemonset, pods, and service account [GH-690](https://github.com/hashicorp/vault-helm/pull/690)
* Add namespace to injector-leader-elector role, rolebinding and secret [GH-683](https://github.com/hashicorp/vault-helm/pull/683)
* Support policy/v1 PodDisruptionBudget in Kubernetes 1.21+ for server and injector [GH-710](https://github.com/hashicorp/vault-helm/pull/710)

## 0.19.0 (January 20th, 2022)

Expand Down
2 changes: 1 addition & 1 deletion templates/injector-disruptionbudget.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{{- if .Values.injector.podDisruptionBudget }}
apiVersion: policy/v1beta1
apiVersion: {{ ge .Capabilities.KubeVersion.Minor "21" | ternary "policy/v1" "policy/v1beta1" }}
kind: PodDisruptionBudget
metadata:
name: {{ template "vault.fullname" . }}-agent-injector
Expand Down
2 changes: 1 addition & 1 deletion templates/server-disruptionbudget.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
{{- if and (eq .mode "ha") (eq (.Values.server.ha.disruptionBudget.enabled | toString) "true") -}}
# PodDisruptionBudget to prevent degrading the server cluster through
# voluntary cluster changes.
apiVersion: policy/v1beta1
apiVersion: {{ ge .Capabilities.KubeVersion.Minor "21" | ternary "policy/v1" "policy/v1beta1" }}
kind: PodDisruptionBudget
metadata:
name: {{ template "vault.fullname" . }}
Expand Down
26 changes: 24 additions & 2 deletions test/unit/injector-disruptionbudget.bats
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,16 @@ load _helpers
[ "${actual}" = "false" ]
}

@test "injector/DisruptionBudget: configure with injector.podDisruptionBudget minAvailable" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-disruptionbudget.yaml \
--set 'injector.podDisruptionBudget.minAvailable=2' \
. | tee /dev/stderr |
yq '.spec.minAvailable == 2' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "injector/DisruptionBudget: configure with injector.podDisruptionBudget maxUnavailable" {
cd `chart_dir`
local actual=$(helm template \
Expand All @@ -21,12 +31,24 @@ load _helpers
[ "${actual}" = "true" ]
}

@test "injector/DisruptionBudget: configure with injector.podDisruptionBudget minAvailable" {
@test "injector/DisruptionBudget: test is apiVersion is set correctly < version 1.21 of kube" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-disruptionbudget.yaml \
--set 'injector.podDisruptionBudget.minAvailable=2' \
--kube-version 1.19.5 \
. | tee /dev/stderr |
yq '.spec.minAvailable == 2' | tee /dev/stderr)
yq '.apiVersion == "policy/v1beta1"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "injector/DisruptionBudget: test is apiVersion is set correctly >= version 1.21 of kube" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/injector-disruptionbudget.yaml \
--set 'injector.podDisruptionBudget.minAvailable=2' \
--kube-version 1.22.5 \
. | tee /dev/stderr |
yq '.apiVersion == "policy/v1"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}
24 changes: 24 additions & 0 deletions test/unit/server-ha-disruptionbudget.bats
Original file line number Diff line number Diff line change
Expand Up @@ -97,3 +97,27 @@ load _helpers
yq '.spec.maxUnavailable' | tee /dev/stderr)
[ "${actual}" = "2" ]
}

@test "server/DisruptionBudget: test is apiVersion is set correctly < version 1.21 of kube" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-disruptionbudget.yaml \
--set 'server.ha.enabled=true' \
--set 'server.ha.replicas=1' \
--kube-version 1.19.5 \
. | tee /dev/stderr |
yq '.apiVersion == "policy/v1beta1"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}

@test "server/DisruptionBudget: test is apiVersion is set correctly >= version 1.21 of kube" {
cd `chart_dir`
local actual=$(helm template \
--show-only templates/server-disruptionbudget.yaml \
--set 'server.ha.enabled=true' \
--set 'server.ha.replicas=1' \
--kube-version 1.22.5 \
. | tee /dev/stderr |
yq '.apiVersion == "policy/v1"' | tee /dev/stderr)
[ "${actual}" = "true" ]
}