Skip to content

Commit

Permalink
Align the podAntiAfiinity rule of envoy
Browse files Browse the repository at this point in the history
Signed-off-by: Lubron Zhan <lubronzhan@gmail.com>
  • Loading branch information
lubronzhan committed Feb 2, 2024
1 parent 6225b42 commit b1497db
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 20 deletions.
13 changes: 6 additions & 7 deletions examples/deployment/03-envoy-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 6 additions & 7 deletions examples/render/contour-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
9 changes: 6 additions & 3 deletions internal/provisioner/objects/dataplane/dataplane.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
},
Expand Down
9 changes: 6 additions & 3 deletions internal/provisioner/objects/dataplane/dataplane_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
},
},
},
},
Expand Down

0 comments on commit b1497db

Please sign in to comment.