Red Hat Training

A Red Hat training course is available for OpenShift Container Platform

16.4.3. 使用自定义调度程序部署 Pod

在集群中部署自定义调度程序后,您可以将 pod 配置为使用该调度程序,而不是默认调度程序。

  1. 创建或编辑 pod 配置,并使用 schedulerName 参数指定调度程序的名称。名称必须是唯一的。

    使用调度程序的 pod 规格示例

    apiVersion: v1
    kind: Pod
    metadata:
      name: custom-scheduler-example
      labels:
        name: custom-scheduler-example
    spec:
      schedulerName: custom-scheduler 1
      containers:
      - name: pod-with-second-annotation-container
        image: docker.io/ocpqe/hello-pod

    1
    要使用的调度程序的名称。如果没有提供调度程序名称,pod 会自动使用默认调度程序来调度。
  2. 运行以下命令来创建 pod:

    $ oc create -f <file-name>.yaml

    例如:

    $ oc create -f custom-scheduler-example.yaml
  3. 运行以下命令来检查 pod 是否已创建:

    $ oc get pod <file-name>

    例如:

    $ oc get pod custom-scheduler-example
    
    NAME                       READY     STATUS    RESTARTS   AGE
    custom-scheduler-example   1/1       Running   0          4m
  4. 运行以下命令来检查自定义调度程序是否调度了 pod:

    $ oc describe pod <pod-name>

    例如:

    $ oc describe pod custom-scheduler-example

    列出了调度程序的名称,如以下截断的输出所示:

    ...
    
    Events:
      FirstSeen  LastSeen  Count  From                SubObjectPath  Type       Reason Message
      ---------  --------  -----  ----                -------------  --------   ------ -------
      1m         1m        1      custom-scheduler    Normal         Scheduled  Successfully assigned custom-scheduler to <$node1>
    
    ...