3.10.6. 根据优先级过滤 pod

只有在优先级低于指定优先级级别时,可以配置 descheduler 策略来考虑 pod 进行驱除。高于指定优先级阈值的 Pod 不视为驱除。

您可以使用 ThresholdPriority 参数设置数字优先级阈值,或者您可以使用 ThresholdPriorityClassName 参数指定特定的优先级类名称。

先决条件

  • 必须具有集群管理员权限。

流程

  1. 编辑 KubeDescheduler 对象:

    $ oc edit kubedeschedulers.operator.openshift.io cluster -n openshift-kube-descheduler-operator
  2. 在一个或多个策略中添加 ThresholdPriorityThresholdPriorityClassName 参数:

    apiVersion: operator.openshift.io/v1beta1
    kind: KubeDescheduler
    metadata:
    ...
    spec:
      deschedulingIntervalSeconds: 3600
      strategies:
      - name: "RemovePodsHavingTooManyRestarts"
        params:
        - name: "PodRestartThreshold"
          value: "10"
        - name: "IncludingInitContainers"
          value: "false"
        - name: "ThresholdPriority" 1
          value: "10000"
      - name: "PodLifeTime"
        params:
        - name: "MaxPodLifeTimeSeconds"
          value: "86400"
        - name: "ThresholdPriorityClassName" 2
          value: "my-priority-class-name" 3
    1 2
    您不能为相同的策略同时指定 ThresholdPriorityThresholdPriorityClassName
    3
    与这个优先级类名关联的数字优先级值被用作阈值。优先级类必须已经存在,解调度程序会抛出错误。
  3. 保存文件以使改变生效。