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

Pr/938: [charts/consul] - Enable terminationGracePeriodSeconds customization on ingressGateway #947

Merged
merged 3 commits into from
Jan 4, 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
## UNRELEASED
IMPROVEMENTS:
* Helm
* Allow customization of `terminationGracePeriodSeconds` on the ingress gateways. [[GH-947](https://github.com/hashicorp/consul-k8s/pull/947)]

## 0.39.0 (December 15, 2021)

Expand Down
2 changes: 1 addition & 1 deletion charts/consul/templates/ingress-gateways-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ spec:
tolerations:
{{ tpl (default $defaults.tolerations .tolerations) $root | nindent 8 | trim }}
{{- end }}
terminationGracePeriodSeconds: 10
terminationGracePeriodSeconds: {{ default $defaults.terminationGracePeriodSeconds .terminationGracePeriodSeconds }}
serviceAccountName: {{ template "consul.fullname" $root }}-{{ .name }}
volumes:
- name: consul-bin
Expand Down
42 changes: 41 additions & 1 deletion charts/consul/test/unit/ingress-gateways-deployment.bats
Original file line number Diff line number Diff line change
Expand Up @@ -1609,4 +1609,44 @@ EOF
[ "${actual}" = "ca" ]
local actual=$(echo $object | yq -r '.metadata.annotations."vault.hashicorp.com/ca-cert"')
[ "${actual}" = "/vault/custom/tls.crt" ]
}
}

#--------------------------------------------------------------------
# terminationGracePeriodSeconds

@test "ingressGateways/Deployment: terminationGracePeriodSeconds defaults to 10" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ingress-gateways-deployment.yaml \
--set 'ingressGateways.enabled=true' \
--set 'connectInject.enabled=true' \
. | tee /dev/stderr |
yq -s -r '.[0].spec.template.spec.terminationGracePeriodSeconds' | tee /dev/stderr)
[ "${actual}" = "10" ]
}

@test "ingressGateways/Deployment: terminationGracePeriodSeconds can be set through defaults" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ingress-gateways-deployment.yaml \
--set 'ingressGateways.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'ingressGateways.defaults.terminationGracePeriodSeconds=5' \
. | tee /dev/stderr |
yq -s -r '.[0].spec.template.spec.terminationGracePeriodSeconds' | tee /dev/stderr)
[ "${actual}" = "5" ]
}

@test "ingressGateways/Deployment: can set terminationGracePeriodSeconds through specific gateway overriding defaults" {
cd `chart_dir`
local actual=$(helm template \
-s templates/ingress-gateways-deployment.yaml \
--set 'ingressGateways.enabled=true' \
--set 'connectInject.enabled=true' \
--set 'ingressGateways.defaults.terminationGracePeriodSeconds=5' \
--set 'ingressGateways.gateways[0].name=gateway1' \
--set 'ingressGateways.gateways[0].terminationGracePeriodSeconds=30' \
. | tee /dev/stderr |
yq -s -r '.[0].spec.template.spec.terminationGracePeriodSeconds' | tee /dev/stderr)
[ "${actual}" = "30" ]
}
3 changes: 3 additions & 0 deletions charts/consul/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2304,6 +2304,9 @@ ingressGateways:
# Optional priorityClassName.
priorityClassName: ""

# Amount of seconds to wait for graceful termination before killing the pod.
terminationGracePeriodSeconds: 10

# Annotations to apply to the ingress gateway deployment. Annotations defined
# here will be applied to all ingress gateway deployments in addition to any
# annotations defined for a specific gateway in `ingressGateways.gateways`.
Expand Down