Would like to know if there are any setting to adjust the graceful shutdown period for sidecar container in kubernetes? As we have found out that the period is too short and want to extend it.
1 Answers
You can use terminationGracePeriodSeconds
From docs (https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.19/#podspec-v1-core):
terminationGracePeriodSeconds
integer Optional duration in seconds the pod needs to terminate gracefully. May be decreased in delete request. Value must be non-negative integer. The value zero indicates delete immediately. If this value is nil, the default grace period will be used instead. The grace period is the duration in seconds after the processes running in the pod are sent a termination signal and the time when the processes are forcibly halted with a kill signal. Set this value longer than the expected cleanup time for your process. Defaults to 30 seconds.
Here is an example:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
app: test
name: test
spec:
replicas: 1
selector:
matchLabels:
app: test
strategy: {}
template:
metadata:
labels:
app: test
spec:
containers:
- image: test
name: test
terminationGracePeriodSeconds: 60 # <----HERE
Additionally you may also want to check the docs about container lifecycle hooks.

- 7,419
- 1
- 11
- 22