[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: Signal Shutdown on Rolling Deployments

All pods are notified via SIGTERM that they should shut down.  You can also register a pre-stop hook in the pod definition that is given a chance to run before SIGTERM is sent.  You must set a longer terminationGracePeriodSeconds if you need more than the default 30s:

$ oc explain pod.spec.terminationGracePeriodSeconds
FIELD: 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

$ oc explain pod.spec.containers.lifecycle.preStop
RESOURCE: preStop <Object>

     PreStop is called immediately before a container is terminated. The
     container is terminated after the handler completes. The reason for
     termination is passed to the handler. Regardless of the outcome of the
     handler, the container is eventually terminated. Other management of the
     container blocks until the hook completes. More info: http://

    Handler defines a specific action that should be taken

   tcpSocket   <Object>
     TCPSocket specifies an action involving a TCP port. TCP hooks not yet

   exec <Object>
     One and only one of the following should be specified. Exec specifies the
     action to take.

   httpGet     <Object>
     HTTPGet specifies the http request to perform.

Note that "other management of he container blocks until the hook completes" means other actions taken by kube against the pod.  The grace period still applies (you will be terminated after that duration).

On Wed, Sep 7, 2016 at 9:54 PM, Frank Liauw <frank vsee com> wrote:

I have a microservice that needs to be signalled before disposal (from say rolling deployments) so that it can shutdown gracefully. 

Is there a way to signal a pod that's impending for shutdown? 


Systems Engineer

users mailing list
users lists openshift redhat com

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]