This page describes scheduler options and how to configure default pod scheduling constraints in your Google Distributed Cloud software-only for bare metal clusters.
Google Distributed Cloud provides a number of standard Kubernetes features that you can use to control scheduling pods, such as:
For information on pod topology spread constraints in Kubernetes, see Kubernetes Scheduler in the Kubernetes documentation.
Before you begin
Before configuring default pod spread, make sure each node in your cluster has the
correct topology labels. You can use the Nodepool.Spec.TaintsAndLabels API
to apply labels. Manually labeling nodes with kubectl label offers more
flexibility, but requires manual labeling when you add a new node to the
cluster.
Configure default custom scheduler {#:config-default}
Label nodes
Add topology labels to your cluster and nodepool YAML files. The following example assumes two worker nodepools are in different racks, and control plane nodes are in
rack1.apiVersion: baremetal.cluster.gke.io/v1 kind: Cluster metadata: name: abm-cluster namespace: cluster-abm-cluster spec: controlPlane: nodePoolSpec: labels: topology.k8s.io/rack: rack1 --- apiVersion: baremetal.cluster.gke.io/v1 kind: NodePool metadata: name: nodepool-rack1 namespace: cluster-abm-cluster spec: labels: topology.k8s.io/rack: rack1 --- apiVersion: baremetal.cluster.gke.io/v1 kind: NodePool metadata: name: nodepool-rack2 namespace: cluster-abm-cluster spec: labels: topology.k8s.io/rack: rack2Apply the updated cluster configuration.
bmctl update cluster -c CLUSTER_NAMEReplace
CLUSTER_NAMEwith the name of your cluster.Wait for the
topology.k8s.io/racklabel to propagate to all nodes in the cluster.
Enable default pod spread constraints
Add the
preview.baremetal.cluster.gke.io/custom-scheduler-configuration:enableannotation to your cluster YAML file.Add the
schedulerConfigurationsection undercluster.spec.controlPlanein your cluster YAML file.apiVersion: baremetal.cluster.gke.io/v1 kind: Cluster metadata: name: abm-cluster namespace: cluster-abm-cluster annotations: preview.baremetal.cluster.gke.io/custom-scheduler-configuration: enable spec: controlPlane: schedulerConfiguration: defaultTopologySpreadConstraint: defaultConstraints: - topologyKey: topology.k8s.io/rack whenUnsatisfiable: DoNotSchedule maxSkew: 1 defaultingType: ListApply the updated cluster configuration.
bmctl update cluster -c CLUSTER_NAMEReplace
CLUSTER_NAMEwith the name of your cluster.Wait for the cluster reconciliation to complete. Monitor
cluster.status.clusterStateuntil it showsRunning. Acontrol-plane-updatejob runs for each control plane node during this process.
Verify pod spread configuration
Create a test deployment with five replicas.
Observe the pod distribution. The difference in the number of pods on
nodepool-rack1andnodepool-rack2should be exactly one.Verify the
kube-scheduler-profile.configfile on each Control Plane node. The file, located at/etc/kubernetes/kube-scheduler-profile.config, must contain the topology spread configuration fromcluster.spec.
Troubleshoot
To diagnose and resolve issues with default pod spread, check the following:
- Review the
BareMetalMachine.Status.ControlPlaneComponentsfor the feature's status. - Examine logs from the
cluster-operatorandcap-controller-managerfor relevant events. - If
kube-schedulerstatic pods crash, check that the scheduler configuration is correct in the cluster YAML file.
What's next
- Learn more about pod topology spread constraints in the Kubernetes documentation.
- See Troubleshoot the Kubernetes scheduler if you run into issues.