Skip to content

Commit

Permalink
Fix service-mirror template when running in HA mode (#11609)
Browse files Browse the repository at this point in the history
Two clusters can be linked in HA mode. When HA values are used, the
service-mirror deployment receives some pod affinity rules to ensure
fair scheduling of pods across a cluster's nodes.

The service-mirror Deployment's template seems to be broken at the
moment when using HA values. Affinity rules are incorrectly grouped
under a top-level `podAntiAffinity` field. The Kubernetes API requires
the rules to be grouped under a top-level `affinity` field. This change
rectifies that by introducing the missing parent.

Fixes #11603

Signed-off-by: Matei David <[email protected]>
  • Loading branch information
mateiidavid authored Nov 22, 2023
1 parent 1b37e19 commit 97ac3dd
Show file tree
Hide file tree
Showing 4 changed files with 205 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,12 @@ spec:
mirror.linkerd.io/cluster-name: {{.Values.targetClusterName}}
{{- with .Values.podLabels }}{{ toYaml . | trim | nindent 8 }}{{- end }}
spec:
{{- if .Values.enablePodAntiAffinity -}}
{{- $local := dict "label" "mirror.linkerd.io/cluster-name" "component" .Values.targetClusterName -}}
{{- include "linkerd.pod-affinity" $local | nindent 6 -}}
{{- if .Values.enablePodAntiAffinity}}
{{- with $tree := deepCopy . }}
{{- $_ := set $tree "component" .Values.targetClusterName -}}
{{- $_ := set $tree "label" "mirror.linkerd.io/cluster-name" -}}
{{- include "linkerd.affinity" $tree | nindent 6 }}
{{- end }}
{{- end }}
containers:
- args:
Expand Down
10 changes: 9 additions & 1 deletion multicluster/cmd/link_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,15 @@ func TestServiceMirrorRender(t *testing.T) {
{
linkValues,
nil,
"serivce_mirror_default.golden",
"service_mirror_default.golden",
},

{
linkValues,
map[string]interface{}{
"enablePodAntiAffinity": true,
},
"service_mirror_ha.golden",
},
}
for i, tc := range testCases {
Expand Down
190 changes: 190 additions & 0 deletions multicluster/cmd/testdata/service_mirror_ha.golden

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 97ac3dd

Please sign in to comment.