Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

configuring kubernetes restart policy

According to the docs -

Failed containers that are restarted by Kubelet, are restarted with an exponential back-off delay, the delay is in multiples of sync-frequency 0, 1x, 2x, 4x, 8x … capped at 5 minutes and is reset after 10 minutes of successful execution.

Is there any way to define a custom RestartPolicy? I want to minimize the back-off delay as much as possible and drop off the exponential behavior.

As far as I can find, you can't even configure the RestartPoilcy, let alone make a new one...

like image 753
user1708860 Avatar asked Dec 12 '16 20:12

user1708860


People also ask

How do I change my Kubernetes restart policy?

Once you created the pod, kubernetes makes some properties immutable. These are mostly the options which can change pods stability, for example this. You can get the manifest using kubectl get pod $PODNAME -o yaml --export . Then edit this manifest and change the restartPolicy field to Never and redeploy it.

What is restart policy in Kubernetes?

restartPolicy only refers to restarts of the containers by the kubelet on the same node. After containers in a Pod exit, the kubelet restarts them with an exponential back-off delay (10s, 20s, 40s, …), that is capped at five minutes.

What is the default restart policy?

In Kubernetes, Always is the default restart policy. With this policy, containers will always be restarted if they stop, even if they completed successfully. This policy should be used for applications that always needs to be running.


1 Answers

The backoff delay is not tunable because it could severely affects the reliability of kubelet. Imagine you have some pods that keep crashing on the node, kubelet will continuously restarting all those pods/containers with no break, consuming a lot of resources.

Why do you want to change the restart backoff delay?

like image 56
Yu-Ju Hong Avatar answered Sep 30 '22 10:09

Yu-Ju Hong