This documentation is for a release that is no longer maintained
See documentation for the latest supported version 3 or the latest supported version 4.3.10.2. 使用自定义调度程序部署 pod
在集群中部署自定义调度程序后,您可以将 pod 配置为使用该调度程序,而不是默认调度程序。
每个调度程序具有集群中资源的单独视图。因此,每个调度程序应在自己的一组节点上运行。
如果两个或多个调度程序在同一节点上运行,它们可能会相互干扰,并在同一个节点上调度多个 pod,而不是用于的可用资源。在这种情况下,Pod 可能会因为资源不足而被拒绝。
先决条件
-
您可以使用具有
cluster-admin
角色的用户访问集群。 - 自定义调度程序已在集群中部署。
流程
如果您的集群使用基于角色的访问控制 (RBAC),将自定义调度程序名称添加到
system:kube-scheduler
集群角色。编辑
system:kube-scheduler
集群角色:oc edit clusterrole system:kube-scheduler
$ oc edit clusterrole system:kube-scheduler
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 将自定义调度程序的名称添加到
leases
和endpoints
的resourceNames
列表中:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
创建
Pod
配置并在schedulerName
参数中指定自定义调度程序的名称:custom-scheduler-example.yaml
文件示例Copy to Clipboard Copied! Toggle word wrap Toggle overflow - 1
- 要使用的自定义调度程序的名称,本例中为
custom-scheduler
。如果没有提供调度程序名称,pod 会自动使用默认调度程序来调度。
创建 pod:
oc create -f custom-scheduler-example.yaml
$ oc create -f custom-scheduler-example.yaml
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
验证
输入以下命令检查 pod 是否已创建:
oc get pod custom-scheduler-example
$ oc get pod custom-scheduler-example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow custom-scheduler-example
pod 在输出中列出:NAME READY STATUS RESTARTS AGE custom-scheduler-example 1/1 Running 0 4m
NAME READY STATUS RESTARTS AGE custom-scheduler-example 1/1 Running 0 4m
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 输入以下命令检查自定义调度程序是否已调度 pod:
oc describe pod custom-scheduler-example
$ oc describe pod custom-scheduler-example
Copy to Clipboard Copied! Toggle word wrap Toggle overflow 调度程序
custom-scheduler
如以下截断的输出所示:Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled <unknown> custom-scheduler Successfully assigned default/custom-scheduler-example to <node_name>
Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled <unknown> custom-scheduler Successfully assigned default/custom-scheduler-example to <node_name>
Copy to Clipboard Copied! Toggle word wrap Toggle overflow