Scheduling pods using a secondary scheduler
You can run a custom secondary scheduler in OpenShift Container Platform by installing the Secondary Scheduler Operator, deploying the secondary scheduler, and setting the secondary scheduler in the pod definition.
Installing the Secondary Scheduler Operator
You can install the Secondary Scheduler Operator for Red Hat OpenShift through the OpenShift Container Platform web console to configure a secondary scheduler.
-
You are logged in to OpenShift Container Platform as a user with the
cluster-adminrole. -
You have access to the OpenShift Container Platform web console.
-
Log in to the OpenShift Container Platform web console.
-
Create the required namespace for the Secondary Scheduler Operator for Red Hat OpenShift.
-
Navigate to Administration → Namespaces and click Create Namespace.
-
Enter
openshift-secondary-scheduler-operatorin the Name field and click Create.
-
-
Install the Secondary Scheduler Operator for Red Hat OpenShift.
-
Navigate to Ecosystem → Software Catalog.
-
Enter Secondary Scheduler Operator for Red Hat OpenShift into the filter box.
-
Select the Secondary Scheduler Operator for Red Hat OpenShift and click Install.
-
On the Install Operator page:
-
The Update channel is set to stable, which installs the latest stable release of the Secondary Scheduler Operator for Red Hat OpenShift.
-
Select A specific namespace on the cluster and select openshift-secondary-scheduler-operator from the drop-down menu.
-
Select an Update approval strategy.
-
The Automatic strategy allows Operator Lifecycle Manager (OLM) to automatically update the Operator when a new version is available.
-
The Manual strategy requires a user with appropriate credentials to approve the Operator update.
-
-
Click Install.
-
-
-
Navigate to Ecosystem → Installed Operators.
-
Verify that Secondary Scheduler Operator for Red Hat OpenShift is listed with a Status of Succeeded.
Deploying a secondary scheduler
After you have installed the Secondary Scheduler Operator, you can deploy a secondary scheduler to apply custom placement logic for specific pods.
-
You are logged in to OpenShift Container Platform as a user with the
cluster-adminrole. -
You have access to the OpenShift Container Platform web console.
-
The Secondary Scheduler Operator for Red Hat OpenShift is installed.
-
Log in to the OpenShift Container Platform web console.
-
Create config map to hold the configuration for the secondary scheduler.
-
Navigate to Workloads → ConfigMaps.
-
Click Create ConfigMap.
-
In the YAML editor, enter the config map definition that contains the necessary
KubeSchedulerConfigurationconfiguration. For example:apiVersion: v1 kind: ConfigMap metadata: name: "secondary-scheduler-config" namespace: "openshift-secondary-scheduler-operator" data: "config.yaml": | apiVersion: kubescheduler.config.k8s.io/v1 kind: KubeSchedulerConfiguration leaderElection: leaderElect: false profiles: - schedulerName: secondary-scheduler plugins: score: disabled: - name: NodeResourcesBalancedAllocation - name: NodeResourcesLeastAllocatedwhere:
metadata.name-
Specifies the name of the config map. This is used in the Scheduler Config field when creating the
SecondarySchedulerCR. metadata.namespace-
Specifies the namespace to create the config map in. The namespace must be
openshift-secondary-scheduler-operator. data."config.yaml".kind-
Specifies the
KubeSchedulerConfigurationresource for the secondary scheduler. For more information, seeKubeSchedulerConfigurationin the Kubernetes API documentation. data."config.yaml".profiles.schedulerName-
Specifies the name of the secondary scheduler. Pods that set their
spec.schedulerNamefield to this value are scheduled with this secondary scheduler. data."config.yaml".profiles.plugins-
Specifies the plugins to enable or disable for the secondary scheduler. For a list default scheduling plugins, see Scheduling plugins in the Kubernetes documentation.
-
Click Create.
-
-
Create the
SecondarySchedulerCR:-
Navigate to Ecosystem → Installed Operators.
-
Select Secondary Scheduler Operator for Red Hat OpenShift.
-
Select the Secondary Scheduler tab and click Create SecondaryScheduler.
-
The Name field defaults to
cluster; do not change this name. -
The Scheduler Config field defaults to
secondary-scheduler-config. Ensure that this value matches the name of the config map created earlier in this procedure. -
In the Scheduler Image field, enter the image name for your custom scheduler.
Important
Red Hat does not directly support the functionality of your custom secondary scheduler.
-
Click Create.
-
Scheduling a pod using the secondary scheduler
To schedule a pod by using the secondary scheduler, set the schedulerName field in the pod definition.
-
You are logged in to OpenShift Container Platform as a user with the
cluster-adminrole. -
You have access to the OpenShift Container Platform web console.
-
The Secondary Scheduler Operator for Red Hat OpenShift is installed.
-
A secondary scheduler is configured.
-
Log in to the OpenShift Container Platform web console.
-
Navigate to Workloads → Pods.
-
Click Create Pod.
-
In the YAML editor, enter the desired pod configuration and add the
schedulerNamefield:apiVersion: v1 kind: Pod metadata: name: nginx namespace: default spec: securityContext: runAsNonRoot: true seccompProfile: type: RuntimeDefault containers: - name: nginx image: nginx:1.14.2 ports: - containerPort: 80 securityContext: allowPrivilegeEscalation: false capabilities: drop: [ALL] schedulerName: secondary-schedulerThe
spec.schedulerNamefield must match the name that is defined in the config map when you configured the secondary scheduler. -
Click Create.
-
Log in to the OpenShift CLI.
-
Describe the pod using the following command:
$ oc describe pod nginx -n defaultExample outputName: nginx Namespace: default Priority: 0 Node: ci-ln-t0w4r1k-72292-xkqs4-worker-b-xqkxp/10.0.128.3 ... Events: Type Reason Age From Message ---- ------ ---- ---- ------- Normal Scheduled 12s secondary-scheduler Successfully assigned default/nginx to ci-ln-t0w4r1k-72292-xkqs4-worker-b-xqkxp ... -
In the events table, find the event with a message similar to
Successfully assigned <namespace>/<pod_name> to <node_name>. -
In the "From" column, verify that the event was generated from the secondary scheduler and not the default scheduler.
Note
You can also check the
secondary-scheduler-*pod logs in theopenshift-secondary-scheduler-namespaceto verify that the pod was scheduled by the secondary scheduler.