Skip to content

Commit 13fa067

Browse files
authored
Add graceful termination to coturn chart (#2456)
* charts/coturn: add support for graceful termination. This adds a preStop hook to coturn pods which waits until the number of active allocations goes to zero before the coturn process is signalled to terminate. This can be used with an external service discovery mechanism to enable graceful rolling restarts, by removing each running coturn pod from the set of active advertised coturn instances in turn. * changelog: add entry for coturn graceful termination feature. * charts/coturn: update coturn container image version. Starting with this version, our coturn image ships with the pre-stop hook script, which is required for graceful termination.
1 parent 04df57d commit 13fa067

File tree

4 files changed

+30
-1
lines changed

4 files changed

+30
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
The coturn chart has new functionality to enable graceful pod termination, by
2+
waiting for all active allocations on a coturn instance to drain first. When
3+
combined with a suitable external service discovery mechanism which can steer
4+
client traffic away from terminating coturn pods, this can be used to implement
5+
graceful rolling restarts of clusters of coturn instances.

charts/coturn/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,4 +11,4 @@ version: 0.0.42
1111
# This is the version number of the application being deployed. This version number should be
1212
# incremented each time you make changes to the application. Versions are not expected to
1313
# follow Semantic Versioning. They should reflect the version the application is using.
14-
appVersion: 4.5.2-wireapp.1
14+
appVersion: 4.5.2-wireapp.5

charts/coturn/templates/statefulset.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ spec:
9393
ZREST_SECRET="$(cat /secrets/zrest_secret.txt)"
9494
sed -Ee "s;__COTURN_EXT_IP__;$EXTERNAL_IP;g" -e "s;__COTURN_POD_IP__;$POD_IP;g" -e "s;__COTURN_SECRET__;$ZREST_SECRET;" /coturn-template/coturn.conf.template > /coturn-config/turnserver.conf
9595
exec /usr/bin/turnserver -c /coturn-config/turnserver.conf
96+
{{- if .Values.coturnGracefulTermination }}
97+
lifecycle:
98+
preStop:
99+
exec:
100+
command:
101+
- /bin/sh
102+
- -c
103+
- exec /usr/local/bin/pre-stop-hook "$POD_IP" {{ .Values.coturnMetricsListenPort }}
104+
{{- end }}
96105

97106
ports:
98107
- name: coturn-tcp
@@ -114,6 +123,9 @@ spec:
114123

115124
resources:
116125
{{- toYaml .Values.resources | nindent 12 }}
126+
{{- if .Values.coturnGracefulTermination }}
127+
terminationGracePeriodSeconds: {{ .Values.coturnGracePeriodSeconds }}
128+
{{- end }}
117129
{{- with .Values.nodeSelector }}
118130
nodeSelector:
119131
{{- toYaml . | nindent 8 }}

charts/coturn/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,3 +24,15 @@ securityContext:
2424

2525
coturnTurnListenPort: 3478
2626
coturnMetricsListenPort: 9641
27+
28+
# This chart optionally supports waiting for traffic to drain from coturn
29+
# before pods are terminated. Warning: coturn does not have any way to steer
30+
# incoming client traffic away from itself on its own, so this functionality
31+
# relies on external traffic management (e.g. service discovery for active coturn
32+
# instances) to prevent clients from sending new requests to pods which are in a
33+
# terminating state.
34+
coturnGracefulTermination: false
35+
# Grace period for terminating coturn pods, after which they will be forcibly
36+
# terminated. This setting is only effective when coturnGracefulTermination is
37+
# set to true.
38+
coturnGracePeriodSeconds: 86400 # one day

0 commit comments

Comments
 (0)