Skip to content

How to configure custom kube-scheduler profiles in a Rancher-provisioned RKE2 cluster

Article Number: 000021703

Environment

  • Rancher v2.6+
  • A Rancher-provisioned RKE2 cluster

Situation

This article details how to configure the Kubernetes scheduler by injecting custom kube-scheduler profiles in a Rancher-provisioned RKE2 cluster.

Cause

To customise the Kubernetes scheduler in an RKE2 cluster a custom kube-scheduler configuration can be injected to achieve this desired result.

Resolution

This solution employs a ConfigMap and machineSelectorFiles to deploy the necessary kube-scheduler configuration to the control-plane nodes within a Rancher-provisioned RKE2 cluster. The following steps are needed:

  1. ConfigMap for kube-scheduler configuration:
apiVersion: v1
kind: ConfigMap
metadata:
  name: kube-scheduler-config
  namespace: fleet-default
  annotations:
    rke.cattle.io/object-authorized-for-clusters: rke2custom
data:
  config: |
    apiVersion: kubescheduler.config.k8s.io/v1
    kind: KubeSchedulerConfiguration
    clientConnection:
      kubeconfig: /var/lib/rancher/rke2/server/cred/scheduler.kubeconfig
    profiles:
    - schedulerName: default-scheduler
    - schedulerName: no-scoring-scheduler
      plugins:
        preScore:
          disabled:
          - name: '*'
            score:
  1. Referencing the ConfigMap in the RKE2 cluster configuration: This is done within the cluster.provisioning.cattle.io rkeConfig.
machineSelectorFiles:
  - fileSources:
    - configMap:
      items:
       - key: config
        path: /kube-scheduler-config
        permissions: '644'
      name: kube-scheduler-config
   machineLabelSelector:
    matchLabels:
     rke.cattle.io/control-plane-role: 'true'
 machineSelectorConfig:
  - config:
    kube-scheduler-arg: 'config=/kube-scheduler-config'
   machineLabelSelector:
    matchLabels:
     rke.cattle.io/control-plane-role: 'true'

Note: The /kube-scheduler-config path is arbitrary and was used for testing purposes