Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/zone redundancy #14399

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
125 commits
Select commit Hold shift + click to select a range
1229a8e
test adding components maping
michaelsudakov Sep 18, 2024
a8cb051
fix typing error
michaelsudakov Sep 18, 2024
d507e1f
fix test
michaelsudakov Sep 18, 2024
694341e
comment in test file
michaelsudakov Sep 18, 2024
2beccf1
uncomment test file
michaelsudakov Sep 18, 2024
9ca02ee
change test v1
michaelsudakov Sep 18, 2024
5fa5f15
fix type error in v1-test
michaelsudakov Sep 18, 2024
95eef9f
fix test
michaelsudakov Sep 18, 2024
c137832
fix type error
michaelsudakov Sep 18, 2024
ff0ae76
fix test
michaelsudakov Sep 18, 2024
348beed
test
michaelsudakov Sep 18, 2024
6b17f03
test
michaelsudakov Sep 18, 2024
0e2a047
test
michaelsudakov Sep 18, 2024
1c1f16e
test
michaelsudakov Sep 18, 2024
81b58ce
deploy loki zone-redundancy
michaelsudakov Sep 19, 2024
85d39ec
fix type error
michaelsudakov Sep 19, 2024
9e15747
fix
michaelsudakov Sep 19, 2024
57cd4e9
fix
michaelsudakov Sep 19, 2024
a5d0676
a
michaelsudakov Sep 19, 2024
cbf7c70
a
michaelsudakov Sep 19, 2024
5cf3144
A
michaelsudakov Sep 19, 2024
b65b9f8
a
michaelsudakov Sep 19, 2024
948c6ac
fix
michaelsudakov Sep 19, 2024
8a04cb6
fix
michaelsudakov Sep 19, 2024
f84b657
fix
michaelsudakov Sep 19, 2024
2a49309
fix
michaelsudakov Sep 19, 2024
d0e178b
fix
michaelsudakov Sep 19, 2024
fb7db07
delete test-v1
michaelsudakov Sep 19, 2024
3a75cd2
fix
michaelsudakov Sep 19, 2024
1d286ed
fix
michaelsudakov Sep 19, 2024
ee2b65c
fix
michaelsudakov Sep 19, 2024
b124ac8
fix
michaelsudakov Sep 19, 2024
48354cc
fix
michaelsudakov Sep 19, 2024
97e364e
fix
michaelsudakov Sep 19, 2024
59d7b8c
d
michaelsudakov Sep 19, 2024
3c0fe95
x
michaelsudakov Sep 19, 2024
abdfecb
fix
michaelsudakov Sep 19, 2024
f990d6e
fix
michaelsudakov Sep 19, 2024
f68cb52
a
michaelsudakov Sep 19, 2024
8956d5f
a
michaelsudakov Sep 19, 2024
52d7528
a
michaelsudakov Sep 19, 2024
b1b3d4c
-
michaelsudakov Sep 19, 2024
0a1bb6a
a
michaelsudakov Sep 19, 2024
aa6a854
a
michaelsudakov Sep 19, 2024
8b75ed1
a
michaelsudakov Sep 19, 2024
3f544ab
a
michaelsudakov Sep 19, 2024
58539e5
a
michaelsudakov Sep 19, 2024
79b4e97
a
michaelsudakov Sep 19, 2024
1a09d68
a
michaelsudakov Sep 19, 2024
2c4b743
a
michaelsudakov Sep 19, 2024
8fd040f
a
michaelsudakov Sep 19, 2024
76d3928
a
michaelsudakov Sep 19, 2024
413f56b
a
michaelsudakov Sep 19, 2024
c6c9798
a
michaelsudakov Sep 19, 2024
e6f3e31
a
michaelsudakov Sep 19, 2024
e1b0ca9
a
michaelsudakov Sep 19, 2024
79c532f
a
michaelsudakov Sep 19, 2024
0cad68c
remove space
michaelsudakov Sep 19, 2024
e08a0f5
remove dot
michaelsudakov Sep 19, 2024
d9ba493
a
michaelsudakov Sep 19, 2024
e077bd9
a
michaelsudakov Sep 19, 2024
a66dca1
remove args and add dot
michaelsudakov Sep 19, 2024
015fe92
.
michaelsudakov Sep 19, 2024
b579b61
.
michaelsudakov Sep 19, 2024
f4c18ee
.
michaelsudakov Sep 19, 2024
a2af484
.
michaelsudakov Sep 19, 2024
e8d4e08
add ctx to selector
michaelsudakov Sep 19, 2024
6da398d
/
michaelsudakov Sep 19, 2024
fe65bd0
a
michaelsudakov Sep 19, 2024
00becd7
.
michaelsudakov Sep 19, 2024
ab8fc8a
-
michaelsudakov Sep 19, 2024
781a516
.
michaelsudakov Sep 19, 2024
bf0efc2
.
michaelsudakov Sep 19, 2024
aa0129a
.
michaelsudakov Sep 19, 2024
b0788ef
test
michaelsudakov Sep 19, 2024
1438608
.
michaelsudakov Sep 19, 2024
5f983ed
service
michaelsudakov Sep 19, 2024
dca1f4a
.
michaelsudakov Sep 19, 2024
7e82c68
.
michaelsudakov Sep 19, 2024
c40dc85
.
michaelsudakov Sep 19, 2024
bf7f5ef
remove space
michaelsudakov Sep 19, 2024
859c2f6
ctx
michaelsudakov Sep 19, 2024
e138b8d
.
michaelsudakov Sep 19, 2024
9b91b9e
.,
michaelsudakov Sep 19, 2024
d48dcfe
a
michaelsudakov Sep 19, 2024
b31c2d4
.
michaelsudakov Sep 19, 2024
f86e5e5
.
michaelsudakov Sep 19, 2024
d2f488f
fix comments on values file
michaelsudakov Sep 23, 2024
f81bd6d
test
michaelsudakov Sep 23, 2024
44dfecd
test
michaelsudakov Sep 23, 2024
07eabf4
test
michaelsudakov Sep 23, 2024
491f16c
a
michaelsudakov Sep 23, 2024
eead4d0
a
michaelsudakov Sep 23, 2024
ca1893e
/
michaelsudakov Sep 23, 2024
f1d7e3a
c
michaelsudakov Sep 23, 2024
c034b24
,
michaelsudakov Sep 23, 2024
6d4deab
.
michaelsudakov Sep 23, 2024
b28d0c4
test
michaelsudakov Sep 23, 2024
dc31931
a
michaelsudakov Sep 23, 2024
71627fe
fix
michaelsudakov Sep 23, 2024
9125ae3
a
michaelsudakov Sep 23, 2024
7f6959a
a
michaelsudakov Sep 23, 2024
d987f49
remove test
michaelsudakov Sep 23, 2024
758e107
try
michaelsudakov Sep 23, 2024
2a89d1f
try
michaelsudakov Sep 23, 2024
9adf447
a
michaelsudakov Sep 23, 2024
b33b075
.
michaelsudakov Sep 23, 2024
fc3c5ef
try
michaelsudakov Sep 23, 2024
ff67318
changed back readinessProbe
michaelsudakov Sep 23, 2024
6a230d0
creating PVCs - default false
michaelsudakov Sep 23, 2024
51d18ed
.
michaelsudakov Sep 23, 2024
70fa0fb
change
michaelsudakov Sep 23, 2024
8abc50c
true
michaelsudakov Sep 23, 2024
5aa88fc
add components to components list
michaelsudakov Sep 24, 2024
e909a23
remove space char
michaelsudakov Sep 24, 2024
36b9a74
added more components
michaelsudakov Sep 24, 2024
4124548
changed persistentVolume to persistence
michaelsudakov Sep 24, 2024
57f7ac8
Merge branch 'main' of https://github.com/Observabiliteam/loki into f…
michaelsudakov Sep 26, 2024
c032fb4
Update _helpers.tpl
ohad2b Sep 26, 2024
8ca8059
fixes
michaelsudakov Sep 26, 2024
8b0e03f
fix
michaelsudakov Sep 26, 2024
4b2b850
FIXED
michaelsudakov Sep 26, 2024
48c16df
fix bloom-builder
michaelsudakov Sep 26, 2024
10adf20
fix bloom-builder
michaelsudakov Sep 26, 2024
78013e5
Update deployment-bloom-builder.yaml
michaelsudakov Oct 6, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
128 changes: 128 additions & 0 deletions production/helm/loki/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,134 @@ Params:
{{- $resourceName -}}
{{- end -}}

{{/*
loki.componentSectionFromName returns the sections from the user .Values in YAML
that corresponds to the requested component. loki.componentSectionFromName takes two arguments
.ctx = the root context of the chart
.component = the name of the component. loki.componentSectionFromName uses an internal mapping to know
which component lives where in the values.yaml
Examples:
$componentSection := include "loki.componentSectionFromName" (dict "ctx" . "component" "ingester") | fromYaml
$componentSection.podLabels ...
*/}}
{{- define "loki.componentSectionFromName" -}}
{{- $componentsMap := dict
"admin-api" "adminApi"
"backend" "backend"
"bloom-compactor" "bloomCompactor"
"bloom-gateway" "bloomGateway"
"chunks-cache" "chunksCache"
"compactor" "compactor"
"distributor" "distributor"
"gateway" "gateway"
"index-gateway" "indexGateway"
"ingester" "ingester"
"memcached" "memcached"
"pattern-ingester" "patternIngester"
"querier" "querier"
"query-frontend" "queryFrontend"
"query-scheduler" "queryScheduler"
"read" "read"
"results-cache" "resultsCache"
"ruler" "ruler"
"single-binary" "singleBinary"
"write" "write"
-}}
{{- $componentSection := index $componentsMap .component -}}
{{- if not $componentSection -}}{{- printf "No component section mapping for %s not found in values; submit a bug report if you are a user, edit loki.componentSectionFromName if you are a contributor" .component | fail -}}{{- end -}}
{{- $section := .ctx.Values -}}
{{- range regexSplit "\\." $componentSection -1 -}}
{{- $section = index $section . -}}
{{- if not $section -}}{{- printf "Component section %s not found in values; values: %s" . ($.ctx.Values | toJson | abbrev 100) | fail -}}{{- end -}}
{{- end -}}
{{- $section | toYaml -}}
{{- end -}}

{{/*
Creates dict for zone-aware replication configuration
Params:
ctx = . context
component = component name
Return value:
{
zoneName: {
affinity: <affinity>,
nodeSelector: <nodeSelector>,
replicas: <N>,
storageClass: <S>
},
...
}
During migration there is a special case where an extra "zone" is generated with zonaName == "" empty string.
The empty string evaluates to false in boolean expressions so it is treated as the default (non zone-aware) zone,
which allows us to keep generating everything for the default zone.
*/}}
{{- define "loki.zoneAwareReplicationMap" -}}
{{- $zonesMap := (dict) -}}
{{- $componentSection := include "loki.componentSectionFromName" . | fromYaml -}}
{{- $defaultZone := (dict "affinity" $componentSection.affinity "nodeSelector" $componentSection.nodeSelector "replicas" $componentSection.replicas "storageClass" $componentSection.storageClass) -}}

{{- if $componentSection.zoneAwareReplication.enabled -}}
{{- $numberOfZones := len $componentSection.zoneAwareReplication.zones -}}
{{- if lt $numberOfZones 3 -}}
{{- fail "When zone-awareness is enabled, you must have at least 3 zones defined." -}}
{{- end -}}

{{- $requestedReplicas := $componentSection.replicas -}}
{{- if and (has .component (list "ingester" )) $componentSection.zoneAwareReplication.migration.enabled (not $componentSection.zoneAwareReplication.migration.writePath) -}}
{{- $requestedReplicas = $componentSection.zoneAwareReplication.migration.replicas }}
{{- end -}}
{{- $replicaPerZone := div (add $requestedReplicas $numberOfZones -1) $numberOfZones -}}

{{- range $idx, $rolloutZone := $componentSection.zoneAwareReplication.zones -}}
{{- $_ := set $zonesMap $rolloutZone.name (dict
"affinity" (($rolloutZone.extraAffinity | default (dict)) | mergeOverwrite (include "loki.zoneAntiAffinity" (dict "component" $.component "rolloutZoneName" $rolloutZone.name "topologyKey" $componentSection.zoneAwareReplication.topologyKey ) | fromYaml ) )
"nodeSelector" ($rolloutZone.nodeSelector | default (dict) )
"replicas" $replicaPerZone
"storageClass" $rolloutZone.storageClass
) -}}
{{- end -}}
{{- if $componentSection.zoneAwareReplication.migration.enabled -}}
{{- if $componentSection.zoneAwareReplication.migration.scaleDownDefaultZone -}}
{{- $_ := set $defaultZone "replicas" 0 -}}
{{- end -}}
{{- $_ := set $zonesMap "" $defaultZone -}}
{{- end -}}

{{- else -}}
{{- $_ := set $zonesMap "" $defaultZone -}}
{{- end -}}
{{- $zonesMap | toYaml }}

{{- end -}}

{{/*
Calculate anti-affinity for a zone
Params:
component = component name
rolloutZoneName = name of the rollout zone
topologyKey = topology key
*/}}
{{- define "loki.zoneAntiAffinity" -}}
{{- if .topologyKey -}}
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: rollout-group
operator: In
values:
- {{ .component }}
- key: zone
operator: NotIn
values:
- {{ .rolloutZoneName }}
topologyKey: {{ .topologyKey | quote }}
{{- else -}}
{}
{{- end -}}
{{- end -}}

{{/*
Return if deployment mode is simple scalable
*/}}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if $isDistributed -}}
apiVersion: apps/v1
kind: Deployment
metadata:
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.ingesterFullname" . }}-headless
name: {{ include "loki.resourceName" (dict "ctx" . "component" "ingester") }}-headless
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
Expand All @@ -28,5 +26,4 @@ spec:
appProtocol: {{ .Values.ingester.appProtocol.grpc }}
{{- end }}
selector:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
{{- end -}}
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}

This file was deleted.

This file was deleted.

This file was deleted.

14 changes: 10 additions & 4 deletions production/helm/loki/templates/ingester/service-ingester.yaml
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
{{- $isDistributed := eq (include "loki.deployment.isDistributed" .) "true" -}}
{{- if and $isDistributed (or (not .Values.ingester.zoneAwareReplication.enabled) .Values.ingester.zoneAwareReplication.migration.enabled) }}
{{- $args := dict "ctx" . "component" "ingester" "memberlist" true -}}
{{- $zonesMap := include "loki.zoneAwareReplicationMap" $args | fromYaml -}}
{{- range $zoneName, $rolloutZone := $zonesMap }}
{{- with $ -}}
{{- $_ := set $args "rolloutZoneName" $zoneName -}}
apiVersion: v1
kind: Service
metadata:
name: {{ include "loki.ingesterFullname" . }}
name: {{ include "loki.resourceName" $args }}
namespace: {{ .Release.Namespace }}
labels:
{{- include "loki.ingesterLabels" . | nindent 4 }}
Expand All @@ -30,4 +33,7 @@ spec:
{{- end }}
selector:
{{- include "loki.ingesterSelectorLabels" . | nindent 4 }}
{{- end -}}
name: {{ include "loki.resourceName" $args }}
---
{{ end }}
{{ end }}
Loading
Loading