Apply changed limits in Kubernetes?

12/4/2019

I changed the limits (default requested amount of CPU) on my Kubernetes cluster. Of course the new limits don't affect already running Pods. So, how can I apply the new (lower) limits to already running Pods.

  1. Is there any way to update the limits in the running Pods without restarting them?
  2. If I have to restart the Pods, how can this be done without deleting and recreating them? (I am really using pure Pods, no Depoyments or so)
-- stefan.at.wpf
kubernetes

3 Answers

12/4/2019

You can do that only when you run it as a deployment, or atleast run a pod with RestartPolicy as RestartAlways, so you can always scale down to zero and scale up to 1 for a safe restart.

In your case, considering that you just run your pod using kubectl run without any restartpolicy, or a restartpolicy as Never, i would run another pod, test and kill the already running ones.

Expect better answers from any one.

-- Srini M
Source: StackOverflow

12/4/2019

You cant change the properties of a running pod. It would reject the changes. Rather you can create a deployment whose rolling update feature ensures,

one pod will be running during the update of limits. There wont be any downtime for your pod.

-- Nikhil Kumar
Source: StackOverflow

12/4/2019

You need to restart the Pods:

  1. You can't update the resources field of a running Pod. The update would be rejected.
  2. You need to create new Pods and delete the old ones. You can create the new ones first and delete the old ones when the new ones are running, if this allows you to avoid downtime.
-- weibeld
Source: StackOverflow