Menu Close

Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

16.2.4. 调度程序策略

选择 predicatepriorities 定义调度程序的策略。

调度程序配置文件是一个 JSON 文件,指定调度程序将考虑的 predicates 和 priorities。

如果没有调度程序策略文件,则会应用默认配置文件 /etc/origin/master/scheduler.json

重要

调度程序配置文件中定义的 predicates 和 priorities 会完全覆盖默认的调度程序策略。如果需要任何默认的 predicates 和 priorities,您必须在调度程序配置文件中明确指定函数。

默认调度程序配置文件

{
    "apiVersion": "v1",
    "kind": "Policy",
    "predicates": [
        {
            "name": "NoVolumeZoneConflict"
        },
        {
            "name": "MaxEBSVolumeCount"
        },
        {
            "name": "MaxGCEPDVolumeCount"
        },
        {
            "name": "MaxAzureDiskVolumeCount"
        },
        {
            "name": "MatchInterPodAffinity"
        },
        {
            "name": "NoDiskConflict"
        },
        {
            "name": "GeneralPredicates"
        },
        {
            "name": "PodToleratesNodeTaints"
        },
        {
            "argument": {
                "serviceAffinity": {
                    "labels": [
                        "region"
                    ]
                }
            },
            "name": "Region"

         }
    ],
    "priorities": [
        {
            "name": "SelectorSpreadPriority",
            "weight": 1
        },
        {
            "name": "InterPodAffinityPriority",
            "weight": 1
        },
        {
            "name": "LeastRequestedPriority",
            "weight": 1
        },
        {
            "name": "BalancedResourceAllocation",
            "weight": 1
        },
        {
            "name": "NodePreferAvoidPodsPriority",
            "weight": 10000
        },
        {
            "name": "NodeAffinityPriority",
            "weight": 1
        },
        {
            "name": "TaintTolerationPriority",
            "weight": 1
        },
        {
            "argument": {
                "serviceAntiAffinity": {
                    "label": "zone"
                }
            },
            "name": "Zone",
            "weight": 2
        }
    ]
}

16.2.4.1. 修改调度程序策略

除非被 master 配置文件中的 kubernetesMasterConfig .schedulerConfigFile 字段覆盖,否则调度程序策略默认在 master 上名为 /etc/origin/master/scheduler. json 的文件中定义

修改的调度程序配置文件示例

kind: "Policy"
version: "v1"
"predicates": [
        {
            "name": "PodFitsResources"
        },
        {
            "name": "NoDiskConflict"
        },
        {
            "name": "MatchNodeSelector"
        },
        {
            "name": "HostName"
        },
        {
            "argument": {
                "serviceAffinity": {
                    "labels": [
                        "region"
                    ]
                }
            },
            "name": "Region"
        }
    ],
    "priorities": [
        {
            "name": "LeastRequestedPriority",
            "weight": 1
        },
        {
            "name": "BalancedResourceAllocation",
            "weight": 1
        },
        {
            "name": "ServiceSpreadingPriority",
            "weight": 1
        },
        {
            "argument": {
                "serviceAntiAffinity": {
                    "label": "zone"
                }
            },
            "name": "Zone",
            "weight": 2
        }
    ]

修改调度程序策略:

  1. 编辑调度程序配置文件,以配置所需的 默认 predicates 和 priorities。您可以创建自定义配置,或使用和修改其中一个 示例策略配置
  2. 添加任何可 配置的 predicates 和 您需要的 可配置优先级
  3. 重启 OpenShift Container Platform 以使更改生效。

    # master-restart api
    # master-restart controllers