diff --git a/examples/deployment/03-envoy-deployment.yaml b/examples/deployment/03-envoy-deployment.yaml index 5236e57fbb1..a05c9a4dace 100644 --- a/examples/deployment/03-envoy-deployment.yaml +++ b/examples/deployment/03-envoy-deployment.yaml @@ -28,14 +28,13 @@ spec: spec: affinity: podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - envoy + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchLabels: + app: envoy topologyKey: "kubernetes.io/hostname" + weight: 100 containers: - command: - /bin/contour diff --git a/examples/render/contour-deployment.yaml b/examples/render/contour-deployment.yaml index b077a0809f9..cdc20ccd279 100644 --- a/examples/render/contour-deployment.yaml +++ b/examples/render/contour-deployment.yaml @@ -9142,14 +9142,13 @@ spec: spec: affinity: podAntiAffinity: - requiredDuringSchedulingIgnoredDuringExecution: - - labelSelector: - matchExpressions: - - key: app - operator: In - values: - - envoy + preferredDuringSchedulingIgnoredDuringExecution: + - podAffinityTerm: + labelSelector: + matchLabels: + app: envoy topologyKey: "kubernetes.io/hostname" + weight: 100 containers: - command: - /bin/contour diff --git a/internal/provisioner/objects/dataplane/dataplane.go b/internal/provisioner/objects/dataplane/dataplane.go index f181189ad76..3da3c6e17e0 100644 --- a/internal/provisioner/objects/dataplane/dataplane.go +++ b/internal/provisioner/objects/dataplane/dataplane.go @@ -433,7 +433,8 @@ func desiredDeployment(contour *model.Contour, contourImage, envoyImage string) Spec: corev1.PodSpec{ Affinity: &corev1.Affinity{ PodAntiAffinity: &corev1.PodAntiAffinity{ - RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{ + PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{ + Weight: int32(100), { LabelSelector: EnvoyPodSelector(contour), TopologyKey: "kubernetes.io/hostname", diff --git a/internal/provisioner/objects/dataplane/dataplane_test.go b/internal/provisioner/objects/dataplane/dataplane_test.go index 4536e9725aa..327bdae602d 100644 --- a/internal/provisioner/objects/dataplane/dataplane_test.go +++ b/internal/provisioner/objects/dataplane/dataplane_test.go @@ -265,7 +265,8 @@ func checkEnvoyDeploymentHasAffinity(t *testing.T, d *appsv1.Deployment, contour if apiequality.Semantic.DeepEqual(*d.Spec.Template.Spec.Affinity, corev1.Affinity{ PodAntiAffinity: &corev1.PodAntiAffinity{ - RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{ + PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{ + Weight: int32(100), { LabelSelector: EnvoyPodSelector(contour), TopologyKey: "kubernetes.io/hostname",