snippetkubernetesMinor
how to control pod termination speed in kubernetes
Viewed 0 times
controlkubernetesterminationhowpodspeed
Problem
I have a k8s deployment that I update by doing
Whenever I update, new pods get created and the old ones eventually get deleted.
This is what
As you can see, the ones in
How can I control the time the old pods remain in
kubectl apply -f spec.yml. I use the default update strategy.Whenever I update, new pods get created and the old ones eventually get deleted.
This is what
kubectl get pods looks like a few seconds after calling apply:NAME READY STATUS RESTARTS AGE
server-243710380-7s7g0 1/1 Terminating 0 9m
server-243710380-ffzv1 1/1 Terminating 0 9m
server-243710380-gfs3h 1/1 Terminating 0 9m
server-3561703442-24dxm 1/1 Running 0 13s
server-3561703442-7jlds 1/1 Running 0 8s
server-3561703442-x5xw1 1/1 Running 0 11sAs you can see, the ones in
Terminating status hang around, typically for about 30 seconds, before really disappearing. This happens despite the new pods reaching running status within a few seconds.How can I control the time the old pods remain in
terminating status? Specifically, I want them to terminate as quickly as possible.Solution
There is a default grace period for pod termination of 30 seconds. See: https://kubernetes.io/docs/concepts/workloads/pods/pod/#termination-of-pods.
You can customize the grace period setting
You can customize the grace period setting
terminationGracePeriodSeconds at the pod spec level.Context
StackExchange DevOps Q#3444, answer score: 8
Revisions (0)
No revisions yet.