Commit 52ed327c authored by Committed by Miciah Dashiel Butler MastersBrowse files
Specify topology spread constraints
Specify topology spread constraints on router deployments to encourage the scheduler to spread router pod replicas across availability zones. Add a to-do to replace the hard anti-affinity rule with soft anti-affinity once the descheduler has support for enforcing soft anti-affinity rules. This commit fixes bug 1900819. https://bugzilla.redhat.com/show_bug.cgi?id=1900819 * pkg/operator/controller/ingress/deployment.go (desiredRouterDeployment): Rename needDeploymentHash to configureAffinity as we now always need to compute the deployment hash but do not always specify an affinity policy. Specify spec.template.spec.topologySpreadConstraints. Specify max skew 1, unsatisfiable-constraint action "ScheduleAnyway", topology key "topology.kubernetes.io/zone", and a label selector on the deployment hash label so as to specify a preference for spreading replicas of the same generation out but not prevent scheduling replicas of different generations on the same node or scheduling more replicas than there are availability zones. Add to-do for changing to soft anti-affinity. (hashableDeployment): Hash spec.template.spec.topologySpreadConstraints. (cmpMatchExpressions, zeroOutDeploymentHash): New functions, factored out of hashableDeployment. * pkg/operator/controller/ingress/deployment_test.go (checkDeploymentHash): New function, factored out of TestDesiredRouterDeployment. (TestDesiredRouterDeployment): Use checkDeploymentHash. Expect the deployment hash label always to be set. (TestDeploymentConfigChanged): Add test cases for spec.template.spec.topologySpreadConstraints.