From 66e9415767a9118a2016f9a5c56a78e566153e72 Mon Sep 17 00:00:00 2001 From: Kirby Chin Date: Fri, 27 Oct 2023 18:41:21 -0400 Subject: [PATCH] Support zone topology for default affinity (#556) * Support zone topology for default affinity * Add zone topology into default pod anti-affinity * Revert utils_test.go changes * Revert utils_test.go changes * Fix spacing in utils_test.go * Lower pod anti-affinity weights * Restore PodAntiAffinity weights --- utils/utils.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/utils/utils.go b/utils/utils.go index d9717160..0559526c 100644 --- a/utils/utils.go +++ b/utils/utils.go @@ -537,7 +537,19 @@ func customizeDefaultAffinity(affinity *corev1.Affinity, name string) { if affinity.PodAntiAffinity == nil { affinity.PodAntiAffinity = &corev1.PodAntiAffinity{} } + term := []corev1.WeightedPodAffinityTerm{ + { + Weight: 50, + PodAffinityTerm: corev1.PodAffinityTerm{ + TopologyKey: "topology.kubernetes.io/zone", + LabelSelector: &metav1.LabelSelector{ + MatchLabels: map[string]string{ + "app.kubernetes.io/instance": name, + }, + }, + }, + }, { Weight: 50, PodAffinityTerm: corev1.PodAffinityTerm{