Skip to content

Commit 77b539b

Browse files
authored
fix: Improve graceful shutdown by adding a pre-stop handler in the k8s deployment (#24)
1 parent 418896a commit 77b539b

File tree

2 files changed

+13
-2
lines changed

2 files changed

+13
-2
lines changed

charts/zero-notifcation-service/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.0.6
18+
version: 0.0.7
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to
2222
# follow Semantic Versioning. They should reflect the version the application is using.
23-
appVersion: 0.0.9
23+
appVersion: 0.0.10

charts/zero-notifcation-service/templates/deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,15 @@ spec:
5151
initialDelaySeconds: 5
5252
periodSeconds: 10
5353
timeoutSeconds: 2
54+
# Some time before the termination signal is sent where the pod will be in a terminating statue and shouldn't receive traffic
55+
# to reduce race conditions where the ingress sends a request to a service that is terminating
56+
lifecycle:
57+
preStop:
58+
exec:
59+
command:
60+
- /bin/sh
61+
- -c
62+
- sleep 5
5463
resources:
5564
{{- toYaml .Values.resources | nindent 12 }}
5665
envFrom:
@@ -70,3 +79,5 @@ spec:
7079
tolerations:
7180
{{- toYaml . | nindent 8 }}
7281
{{- end }}
82+
# Prestop from above plus supplied grace period plus a small buffer
83+
terminationGracePeriodSeconds: {{ add 7 .Values.application.gracefulShutdownTimeout }}

0 commit comments

Comments
 (0)