简体   繁体   中英

changing Pod priority without restarting the Pod?

I am trying to change priority of an existing Kubernetes Pod using 'patch' command, but it returns error saying that this is not one of the fields that can be modified. I can patch the priority in the Deployment spec, but it would cause the Pod to be recreated (following the defined update strategy).

The basic idea is to implement a mechanism conceptually similar to nice levels (for my application), so that certain Pods can be de-prioritized based on certain conditions (by my controller), and preempted by the default scheduler in case of resource congestion. But I don't want them to be restarted if there is no congestion.

Is there a way around it, or there is something inherent in the way scheduler works that would prevent something like this from working properly?

Priority values are applied to a pod based on the priority value of the PriorityClass assigned to their deployment at the time that the pod is scheduled. Any changes made to the PriorityClass will not be applied to pods which have already been scheduled, so you would have to redeploy the pod for the priority to take effect anyway.

As far I know,

Pod priority will work on when pod is getting scheduled.

  1. First you need to create PriorityClasses

  2. Create Pod with priorityClassName and mention priorityclass in pod definition.

If you are trying to add priority to already scheduled pod I will not work.

For reference: https://kubernetes.io/docs/concepts/configuration/pod-priority-preemption/#pod-priority

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM