简体   繁体   English

Kubernetes的Pods的优先事项

[英]Priorities in Pods in Kubernetes

I have some burstable pods running in cluster, which I do not want to be killed in case of memory/cpu pressure. 我有一些在集群中运行的burstable pod,我不希望在内存/ CPU压力的情况下被杀死。

Is there any way to increase it's priority or something, so that we do not have to change it's namespace (kube-system for making it critical) and it can be saved? 有没有办法增加它的优先级或其他东西,这样我们就不必改变它的名称空间(kube-system使它变得至关重要)并且可以保存它?

I have found some issues regarding adding priority to pods. 我发现了一些有关为pod添加优先级的问题 But couldn't figure out the solution. 但无法弄清楚解决方案。 There should be some way to set priority, or am I missing something big here ? 应该有一些方法来设置优先级,还是我错过了一些大的东西?

Pod priority feature is not available prior to Kubernetes v1.7 波德优先功能不可用之前Kubernetes v1.7

From v1.8+ , you can add pod's priority in PodSpec. v1.8+ ,您可以在PodSpec中添加pod的优先级。 You need to create PriorityClass object with priority value and use that PriorityClass name in Pod. 您需要使用优先级值创建PriorityClass对象,并在Pod中使用该PriorityClass名称。

But upto v1.9 , PriorityClass is still in alpha phase. 但是高达v1.9 ,PriorityClass仍处于alpha阶段。

apiVersion: scheduling.k8s.io/v1alpha1
kind: PriorityClass
metadata:
  name: high-priority
value: 1000000
globalDefault: false

Here, 这里,

  • value indicates priority. value表示优先级。 The higher the value, the higher the priority 值越高,优先级越高
  • globalDefault indicates that the value of this PriorityClass should be used for Pods without a PriorityClassName. globalDefault指示此PriorityClass的值应该用于没有PriorityClassName的globalDefault Only one PriorityClass with globalDefault set to true can exist in the system. 系统中只能存在一个globalDefault设置为true的PriorityClass。

Now, lets create a Pod with this Priority 现在,让我们创建一个具有此优先级的Pod

apiVersion: v1
kind: Pod
metadata:
  name: nginx
  labels:
    env: test
spec:
  containers:
  - name: nginx
    image: nginx
  priorityClassName: high-priority

Preemption 抢占

When Pod is created, if no Node is found that satisfies all the specified requirements of that Pod, using preemption logic one or more lower priority Pods get deleted from the Node. 创建Pod时,如果找不到满足该Pod的所有指定要求的Node,则使用抢占逻辑从节点中删除一个或多个低优先级Pod。 After the Pods are gone, Pod with higher priority is scheduled on the Node. 在Pod消失后,Node上会安排具有更高优先级的Pod。

See details about pod priority . 有关pod优先级的详细信息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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