K8S Cluster level topology spread

477 Views Asked by At

EKS 1.23

Trying to set default podTopologySpead on cluster level. Using the suggested config from k8s documentation: https://kubernetes.io/docs/concepts/scheduling-eviction/topology-spread-constraints/#cluster-level-default-constraints :

apiVersion: kubescheduler.config.k8s.io/v1beta3
kind: KubeSchedulerConfiguration

profiles:
  - schedulerName: default-scheduler
    pluginConfig:
      - name: PodTopologySpread
        args:
          defaultConstraints:
            - maxSkew: 1
              topologyKey: topology.kubernetes.io/zone
              whenUnsatisfiable: ScheduleAnyway
          defaultingType: List

when applying I get the following error:

➜ kubectl apply -f ./topology-test
error: unable to recognize "./topology-test": no matches for kind "KubeSchedulerConfiguration" in version "kubescheduler.config.k8s.io/v1beta3"

Also tried to change api version to v1beta1, v1beta2,v1alpha1,v1.

another question regarding it: isn't this configuration requires namespace mention?

1

There are 1 best solutions below

5
Sibtain On

You can customize the behavior of the kube-scheduler by writing a configuration file and passing its path as a command line argument.

You need to pass configuration as an argument to the kube-scheduler like kube-scheduler --config <filename>.

Additionally you can run kubectl api-versions to print the supported API versions on the server.

Please refer the docs for details

UPDATE

As it seems, you cannot update the default-scheduler in EKS, you will need to create a custom scheduler in EKS and then pass in your KubeSchedulerConfiguration within the new scheduler, a sample YAML for it can be found here.

Also check this related SO question about kube-scheduler in EKS