Skip to content

Commit b8c64c3

Browse files
committed
fix affinity
Signed-off-by: AvivGuiser <avivguiser@gmail.com>
1 parent 2b91d83 commit b8c64c3

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

charts/tempo-distributed/templates/ingester/_helpers-ingester.tpl

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,20 +6,20 @@
66
{{- $zonesMap := (dict) -}}
77
{{- $defaultZone := (dict "affinity" .ctx.Values.ingester.affinity "nodeSelector" .ctx.Values.ingester.nodeSelector "replicas" .ctx.Values.ingester.replicas "storageClass" .ctx.Values.ingester.storageClass) -}}
88
{{- if .ctx.Values.ingester.zoneAwareReplication.enabled -}}
9-
{{- $numberOfZones := len .ctx.Values.ingester.zoneAwareReplication.zones -}}
10-
{{- if lt $numberOfZones 3 -}}
11-
{{- fail "When zone-awareness is enabled, you must have at least 3 zones defined." -}}
12-
{{- end -}}
13-
{{- $requestedReplicas := .ctx.Values.ingester.replicas -}}
14-
{{- $replicaPerZone := div (add $requestedReplicas $numberOfZones -1) $numberOfZones -}}
15-
{{- range $idx, $rolloutZone := .ctx.Values.ingester.zoneAwareReplication.zones -}}
16-
{{- $_ := set $zonesMap $rolloutZone.name (dict
17-
"affinity" (($rolloutZone.extraAffinity | default (dict)) | mergeOverwrite (include "ingester.zoneAntiAffinity" (dict "rolloutZoneName" $rolloutZone.name "topologyKey" $.ctx.Values.ingester.zoneAwareReplication.topologyKey) | fromYaml))
18-
"nodeSelector" ($rolloutZone.nodeSelector | default (dict) )
19-
"replicas" $replicaPerZone
20-
"storageClass" $rolloutZone.storageClass
21-
) -}}
22-
{{- end -}}
9+
{{- $numberOfZones := len .ctx.Values.ingester.zoneAwareReplication.zones -}}
10+
{{- if lt $numberOfZones 3 -}}
11+
{{- fail "When zone-awareness is enabled, you must have at least 3 zones defined." -}}
12+
{{- end -}}
13+
{{- $requestedReplicas := .ctx.Values.ingester.replicas -}}
14+
{{- $replicaPerZone := div (add $requestedReplicas $numberOfZones -1) $numberOfZones -}}
15+
{{- range $idx, $rolloutZone := .ctx.Values.ingester.zoneAwareReplication.zones -}}
16+
{{- $_ := set $zonesMap $rolloutZone.name (dict
17+
"affinity" (($rolloutZone.extraAffinity | default (dict)) | mergeOverwrite (include "ingester.zoneAntiAffinity" (dict "rolloutZoneName" $rolloutZone.name "topologyKey" $.ctx.Values.ingester.zoneAwareReplication.topologyKey) | fromYaml))
18+
"nodeSelector" ($rolloutZone.nodeSelector | default (dict) )
19+
"replicas" $replicaPerZone
20+
"storageClass" $rolloutZone.storageClass
21+
) -}}
22+
{{- end -}}
2323
{{- else -}}
2424
{{- $_ := set $zonesMap "" $defaultZone -}}
2525
{{- end -}}

charts/tempo-distributed/templates/ingester/statefulset-ingester.yaml

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ metadata:
1111
labels:
1212
{{- include "ingester.labels" $dict | indent 4 }}
1313
{{- if .Values.ingester.zoneAwareReplication.enabled }}
14-
annotations:
14+
annotations:
1515
{{- include "ingester.Annotations" $dict | nindent 4}}
1616
{{- else }}
1717
{{- with .Values.ingester.annotations }}
@@ -125,10 +125,18 @@ spec:
125125
{{- tpl . $ | nindent 8 }}
126126
{{- end }}
127127
{{- end }}
128+
{{- if eq $zoneName ""}}
129+
{{- with $rolloutZone.affinity }}
130+
affinity:
131+
{{- tpl . $ | nindent 8 }}
132+
{{- end }}
133+
{{- end }}
134+
{{- if ne $zoneName "" }}
128135
{{- with $rolloutZone.affinity }}
129136
affinity:
130137
{{- toYaml . | nindent 8 }}
131138
{{- end }}
139+
{{- end }}
132140
{{- with $rolloutZone.nodeSelector }}
133141
nodeSelector:
134142
{{- toYaml . | nindent 8 }}
@@ -184,4 +192,4 @@ spec:
184192
{{- end }}
185193
---
186194
{{ end }}
187-
{{ end }}
195+
{{ end }}

0 commit comments

Comments
 (0)