Extend Kubernetes termination grace time period of pod runtime

4/1/2020

I am working on the graceful termination, and created a pre-stop script that execute before the pod termination which has the logic which communicate with application via API and based on the response will continue the termination. Is it possible to extend the grace period if the response from the application is not to terminate? , just like life cycle hook on AWS auto scale extend heartbeat timeout.

-- akhil krishna
kubernetes
kubernetes-pod

1 Answer

4/1/2020

You must modify terminationGracePeriodSeconds if the preStop hook needs longer to complete.

          lifecycle:
            preStop:
              exec:
                command:
                  - sh
                  - '-c'
                  - sleep 30; echo terminated

       terminationGracePeriodSeconds: 120
-- ANISH KUMAR MOURYA
Source: StackOverflow