Alex Tbk
Alex Tbk

Reputation: 2104

Setup delay for pod shutdown on update

Is it possible to setup a delay for pod shutdowns after a rolling update on Kubernetes?

For example I roll out a new version and want the old Pods to run for further 15secs after the new instance has been started.

How can I manage that?

Upvotes: 1

Views: 236

Answers (1)

Emruz Hossain
Emruz Hossain

Reputation: 5528

Yes, you can use PreStop Hook to achieve that.

PreStop hooks are executed after a Pod is marked as terminating. See what happen when you delete a pod from here.

You just have to run sleep 15 on PreStop Hook.

For more details see Container hooks.

See how to add a PreStop hook from here: Define postStart and preStop handlers.

Upvotes: 3

Related Questions