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..792eacaffbf 100644 --- a/internal/provisioner/objects/dataplane/dataplane.go +++ b/internal/provisioner/objects/dataplane/dataplane.go @@ -433,10 +433,13 @@ func desiredDeployment(contour *model.Contour, contourImage, envoyImage string) Spec: corev1.PodSpec{ Affinity: &corev1.Affinity{ PodAntiAffinity: &corev1.PodAntiAffinity{ - RequiredDuringSchedulingIgnoredDuringExecution: []corev1.PodAffinityTerm{ + PreferredDuringSchedulingIgnoredDuringExecution: []corev1.WeightedPodAffinityTerm{ { - LabelSelector: EnvoyPodSelector(contour), - TopologyKey: "kubernetes.io/hostname", + Weight: int32(100), + PodAffinityTerm: corev1.PodAffinityTerm{ + 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..928a9b7e631 100644 --- a/internal/provisioner/objects/dataplane/dataplane_test.go +++ b/internal/provisioner/objects/dataplane/dataplane_test.go @@ -265,10 +265,13 @@ 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{ { - LabelSelector: EnvoyPodSelector(contour), - TopologyKey: "kubernetes.io/hostname", + Weight: int32(100), + PodAffinityTerm: corev1.PodAffinityTerm{ + LabelSelector: EnvoyPodSelector(contour), + TopologyKey: "kubernetes.io/hostname", + }, }, }, },