concept terminationgraceperiodsecond in category kubernetes

This is an excerpt from Manning's book Kubernetes in Action, Second Edition MEAP V05.
The application is given a certain amount of time to terminate. This time can be configured using the terminationGracePeriodSeconds field in the pod’s spec and defaults to 30 seconds. The timer starts when the pre-stop hook is called or when the TERM signal is sent if no hook is defined. If the process is still running after the termination grace period has expired, it’s terminated by force via the KILL signal. This terminates the container.
You could set the pod’s terminationGracePeriodSeconds field to a lower value, as shown in the following listing, and see if the pod shuts down faster.
Listing 6.20 Setting a lower terminationGracePeriodSeconds for faster pod shutdown apiVersion: v1 kind: Pod metadata: name: kubia-ssl-shortgraceperiod spec: terminationGracePeriodSeconds: 5 #A containers: ...In the listing above, the pod’s terminationGracePeriodSeconds is set to 5. If you create and then delete this pod, you’ll see that its containers are terminated within 5s of receiving the TERM signal.