-
Notifications
You must be signed in to change notification settings - Fork 2.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3145 from KyriosGN0/tempo-distributed-feat-add-zo…
…ne-aware [tempo-distributed] feat: add zone aware replication
- Loading branch information
Showing
7 changed files
with
296 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
179 changes: 176 additions & 3 deletions
179
charts/tempo-distributed/templates/ingester/_helpers-ingester.tpl
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,180 @@ | ||
{{/* | ||
ingester imagePullSecrets | ||
*/}} | ||
{{- define "tempo.ingesterImagePullSecrets" -}} | ||
{{- $dict := dict "tempo" .Values.tempo.image "component" .Values.ingester.image "global" .Values.global.image -}} | ||
{{- include "tempo.imagePullSecrets" $dict -}} | ||
{{- end }} | ||
{{- define "ingester.zoneAwareReplicationMap" -}} | ||
{{- $zonesMap := (dict) -}} | ||
{{- $defaultZone := (dict "affinity" .ctx.Values.ingester.affinity "nodeSelector" .ctx.Values.ingester.nodeSelector "replicas" .ctx.Values.ingester.replicas "storageClass" .ctx.Values.ingester.storageClass) -}} | ||
{{- if .ctx.Values.ingester.zoneAwareReplication.enabled -}} | ||
{{- $numberOfZones := len .ctx.Values.ingester.zoneAwareReplication.zones -}} | ||
{{- if lt $numberOfZones 3 -}} | ||
{{- fail "When zone-awareness is enabled, you must have at least 3 zones defined." -}} | ||
{{- end -}} | ||
{{- $requestedReplicas := .ctx.Values.ingester.replicas -}} | ||
{{- $replicaPerZone := div (add $requestedReplicas $numberOfZones -1) $numberOfZones -}} | ||
{{- range $idx, $rolloutZone := .ctx.Values.ingester.zoneAwareReplication.zones -}} | ||
{{- $_ := set $zonesMap $rolloutZone.name (dict | ||
"affinity" (($rolloutZone.extraAffinity | default (dict)) | mergeOverwrite (include "ingester.zoneAntiAffinity" (dict "rolloutZoneName" $rolloutZone.name "topologyKey" $.ctx.Values.ingester.zoneAwareReplication.topologyKey) | fromYaml)) | ||
"nodeSelector" ($rolloutZone.nodeSelector | default (dict) ) | ||
"replicas" $replicaPerZone | ||
"storageClass" $rolloutZone.storageClass | ||
) -}} | ||
{{- end -}} | ||
{{- $zonesMap | toYaml }} | ||
{{- end -}} | ||
{{- end -}} | ||
{{/* | ||
Calculate anti-affinity for a zone | ||
Params: | ||
rolloutZoneName = name of the rollout zone | ||
topologyKey = topology key | ||
*/}} | ||
{{- define "ingester.zoneAntiAffinity" -}} | ||
{{- if .topologyKey -}} | ||
podAntiAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
- labelSelector: | ||
matchExpressions: | ||
- key: rollout-group | ||
operator: In | ||
values: | ||
- ingester | ||
- key: zone | ||
operator: NotIn | ||
values: | ||
- {{ .rolloutZoneName }} | ||
topologyKey: {{ .topologyKey | quote }} | ||
{{- else -}} | ||
{} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
Calculate annotations with zone-awareness | ||
Params: | ||
ctx = . context | ||
component = component name | ||
rolloutZoneName = rollout zone name (optional) | ||
*/}} | ||
{{- define "ingester.Annotations" -}} | ||
{{- if and .ctx.Values.ingester.zoneAwareReplication.maxUnavailable .rolloutZoneName }} | ||
{{- $map := dict "rollout-max-unavailable" (.ctx.Values.ingester.zoneAwareReplication.maxUnavailable | toString) -}} | ||
{{- toYaml (deepCopy $map | mergeOverwrite .ctx.Values.ingester.annotations) }} | ||
{{- else -}} | ||
{{ toYaml .ctx.Values.ingester.annotations }} | ||
{{- end -}} | ||
{{- end -}} | ||
|
||
{{/* | ||
ingester labels | ||
*/}} | ||
{{- define "ingester.labels" -}} | ||
{{- if and .ctx.Values.ingester.zoneAwareReplication.enabled .rolloutZoneName }} | ||
name: {{ printf "%s-%s" .component .rolloutZoneName }} | ||
rollout-group: {{ .component }} | ||
zone: {{ .rolloutZoneName }} | ||
{{- end }} | ||
helm.sh/chart: {{ include "tempo.chart" .ctx }} | ||
app.kubernetes.io/name: {{ include "tempo.name" .ctx }} | ||
app.kubernetes.io/instance: {{ .ctx.Release.Name }} | ||
{{- if .component }} | ||
app.kubernetes.io/component: {{ .component }} | ||
{{- end }} | ||
{{- if .memberlist }} | ||
app.kubernetes.io/part-of: memberlist | ||
{{- end }} | ||
{{- if .ctx.Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ .ctx.Chart.AppVersion | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .ctx.Release.Service }} | ||
{{- end -}} | ||
{{/* | ||
Resource name template | ||
*/}} | ||
{{- define "ingester.resourceName" -}} | ||
{{- $resourceName := include "tempo.fullname" .ctx -}} | ||
{{- if .component -}}{{- $resourceName = printf "%s-%s" $resourceName .component -}}{{- end -}} | ||
{{- if .rolloutZoneName -}}{{- $resourceName = printf "%s-%s" $resourceName .rolloutZoneName -}}{{- end -}} | ||
{{- $resourceName -}} | ||
{{- end -}} | ||
|
||
|
||
{{/* | ||
ingester selector labels | ||
Params: | ||
ctx = . context | ||
component = name of the component | ||
rolloutZoneName = rollout zone name (optional) | ||
*/}} | ||
{{- define "ingester.selectorLabels" -}} | ||
{{- if .ctx.Values.enterprise.legacyLabels }} | ||
{{- if .component -}} | ||
app: {{ include "tempo.name" .ctx }}-{{ .component }} | ||
{{- end }} | ||
release: {{ .ctx.Release.Name }} | ||
{{- else -}} | ||
app.kubernetes.io/name: {{ include "tempo.name" .ctx }} | ||
app.kubernetes.io/instance: {{ .ctx.Release.Name }} | ||
{{- if .component }} | ||
app.kubernetes.io/component: {{ .component }} | ||
{{- end }} | ||
{{- end -}} | ||
{{- if .rolloutZoneName }} | ||
{{- if not .component }} | ||
{{- printf "Component name cannot be empty if rolloutZoneName (%s) is set" .rolloutZoneName | fail }} | ||
{{- end }} | ||
rollout-group: {{ .component }} | ||
zone: {{ .rolloutZoneName }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{/* | ||
ingester POD labels | ||
Params: | ||
ctx = . context | ||
component = name of the component | ||
memberlist = true if part of memberlist gossip ring | ||
rolloutZoneName = rollout zone name (optional) | ||
*/}} | ||
{{- define "ingester.podLabels" -}} | ||
{{ with .ctx.Values.global.podLabels -}} | ||
{{ toYaml . }} | ||
{{ end }} | ||
{{- if .ctx.Values.enterprise.legacyLabels }} | ||
{{- if .component -}} | ||
app: {{ include "tempo.name" .ctx }}-{{ .component }} | ||
{{- if not .rolloutZoneName }} | ||
name: {{ .component }} | ||
{{- end }} | ||
{{- end }} | ||
{{- if .memberlist }} | ||
gossip_ring_member: "true" | ||
{{- end -}} | ||
{{- if .component }} | ||
target: {{ .component }} | ||
release: {{ .ctx.Release.Name }} | ||
{{- end }} | ||
{{- else -}} | ||
helm.sh/chart: {{ include "tempo.chart" .ctx }} | ||
app.kubernetes.io/name: {{ include "tempo.name" .ctx }} | ||
app.kubernetes.io/instance: {{ .ctx.Release.Name }} | ||
app.kubernetes.io/version: {{ .ctx.Chart.AppVersion | quote }} | ||
app.kubernetes.io/managed-by: {{ .ctx.Release.Service }} | ||
{{- if .component }} | ||
app.kubernetes.io/component: {{ .component }} | ||
{{- end }} | ||
{{- if .memberlist }} | ||
app.kubernetes.io/part-of: memberlist | ||
{{- end }} | ||
{{- end }} | ||
{{- with .ctx.Values.ingester.podLabels }} | ||
{{ toYaml . }} | ||
{{- end }} | ||
{{- if .rolloutZoneName }} | ||
{{- if not .component }} | ||
{{- printf "Component name cannot be empty if rolloutZoneName (%s) is set" .rolloutZoneName | fail }} | ||
{{- end }} | ||
rollout-group: ingester | ||
zone: {{ .rolloutZoneName }} | ||
{{- end }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.