Skip to content

Commit f629832

Browse files
committed
Add zone awareness support for ingester
1 parent 9cddc01 commit f629832

20 files changed

Lines changed: 1232 additions & 4 deletions

templates/distributor/distributor-dep.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,9 @@ spec:
5454
args:
5555
- "-target=distributor"
5656
- "-config.file=/etc/cortex/cortex.yaml"
57+
{{- if .Values.ingester.zoneAwareness.enabled }}
58+
- -distributor.zone-awareness-enabled={{ not .Values.ingester.zoneAwareness.migration.enabled }}
59+
{{- end }}
5760
{{- range $key, $value := .Values.distributor.extraArgs }}
5861
- "-{{ $key }}={{ $value }}"
5962
{{- end }}
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{{- if and (not .Values.ingester.statefulSet.enabled) .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "cortex.ingesterFullname" . }}-zone-a
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "cortex.ingesterLabels" . | nindent 4 }}
9+
app.kubernetes.io/part-of: memberlist
10+
zone: a
11+
annotations:
12+
{{- toYaml .Values.ingester.zoneAwareness.zoneA.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }}
13+
spec:
14+
{{- if not .Values.ingester.autoscaling.enabled }}
15+
replicas: {{ .Values.ingester.zoneAwareness.zoneA.replicas | default .Values.ingester.replicas }}
16+
{{- end }}
17+
selector:
18+
matchLabels:
19+
{{- include "cortex.ingesterSelectorLabels" . | nindent 6 }}
20+
zone: a
21+
strategy:
22+
{{- toYaml .Values.ingester.strategy | nindent 4 }}
23+
template:
24+
metadata:
25+
labels:
26+
{{- include "cortex.ingesterLabels" . | nindent 8 }}
27+
app.kubernetes.io/part-of: memberlist
28+
zone: a
29+
{{- with .Values.ingester.podLabels }}
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
{{- with .Values.ingester.zoneAwareness.zoneA.podLabels }}
33+
{{- toYaml . | nindent 8 }}
34+
{{- end }}
35+
annotations:
36+
checksum/config: {{ include "cortex.configChecksum" . }}
37+
{{- with .Values.ingester.podAnnotations }}
38+
{{- toYaml . | nindent 8 }}
39+
{{- end }}
40+
{{- with .Values.ingester.zoneAwareness.zoneA.podAnnotations }}
41+
{{- toYaml . | nindent 8 }}
42+
{{- end }}
43+
spec:
44+
serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }}
45+
{{- if .Values.ingester.priorityClassName }}
46+
priorityClassName: {{ .Values.ingester.priorityClassName }}
47+
{{- end }}
48+
{{- if .Values.ingester.securityContext.enabled }}
49+
securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }}
50+
{{- end }}
51+
initContainers:
52+
{{- toYaml .Values.ingester.initContainers | nindent 8 }}
53+
{{- if .Values.image.pullSecrets }}
54+
imagePullSecrets:
55+
{{- range .Values.image.pullSecrets }}
56+
- name: {{ . }}
57+
{{- end }}
58+
{{- end }}
59+
containers:
60+
- name: ingester
61+
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
62+
imagePullPolicy: {{ .Values.image.pullPolicy }}
63+
args:
64+
- "-target=ingester"
65+
- "-config.file=/etc/cortex/cortex.yaml"
66+
- "-ingester.availability-zone=zone-a"
67+
{{- include "cortex.memcached" . | nindent 12 }}
68+
{{- range $key, $value := .Values.ingester.extraArgs }}
69+
- "-{{ $key }}={{ $value }}"
70+
{{- end }}
71+
volumeMounts:
72+
{{- if .Values.ingester.extraVolumeMounts }}
73+
{{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }}
74+
{{- end }}
75+
- name: config
76+
mountPath: /etc/cortex
77+
- name: runtime-config
78+
mountPath: /etc/cortex-runtime-config
79+
- name: storage
80+
mountPath: "/data"
81+
{{- with .Values.ingester.persistentVolume.subPath }}
82+
subPath: {{ . }}
83+
{{- end }}
84+
ports:
85+
- name: http-metrics
86+
containerPort: {{ .Values.config.server.http_listen_port }}
87+
protocol: TCP
88+
- name: grpc
89+
containerPort: {{ .Values.config.server.grpc_listen_port }}
90+
protocol: TCP
91+
- name: gossip
92+
containerPort: {{ .Values.config.memberlist.bind_port }}
93+
protocol: TCP
94+
{{- if .Values.ingester.startupProbe }}
95+
startupProbe:
96+
{{- toYaml .Values.ingester.startupProbe | nindent 12 }}
97+
{{- end }}
98+
{{- if .Values.ingester.livenessProbe }}
99+
livenessProbe:
100+
{{- toYaml .Values.ingester.livenessProbe | nindent 12 }}
101+
{{- end }}
102+
readinessProbe:
103+
{{- toYaml .Values.ingester.readinessProbe | nindent 12 }}
104+
resources:
105+
{{- toYaml .Values.ingester.resources | nindent 12 }}
106+
{{- if .Values.ingester.containerSecurityContext.enabled }}
107+
securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }}
108+
{{- end }}
109+
{{- if .Values.ingester.env }}
110+
env:
111+
{{- toYaml .Values.ingester.env | nindent 12 }}
112+
{{- end }}
113+
{{- with .Values.ingester.lifecycle }}
114+
lifecycle:
115+
{{- toYaml . | nindent 12 }}
116+
{{- end }}
117+
{{- with .Values.ingester.extraContainers }}
118+
{{- toYaml . | nindent 8 }}
119+
{{- end }}
120+
nodeSelector:
121+
{{- if .Values.ingester.zoneAwareness.zoneA.nodeSelector }}
122+
{{- toYaml .Values.ingester.zoneAwareness.zoneA.nodeSelector | nindent 8 }}
123+
{{- else }}
124+
{{- toYaml .Values.ingester.nodeSelector | nindent 8 }}
125+
{{- end }}
126+
{{- if .Values.ingester.topologySpreadConstraints }}
127+
topologySpreadConstraints:
128+
{{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }}
129+
{{- end }}
130+
affinity:
131+
{{- if .Values.ingester.zoneAwareness.zoneA.extraAffinity }}
132+
{{- toYaml .Values.ingester.zoneAwareness.zoneA.extraAffinity | nindent 8 }}
133+
{{- else }}
134+
{{- toYaml .Values.ingester.affinity | nindent 8 }}
135+
{{- end }}
136+
tolerations:
137+
{{- if .Values.ingester.zoneAwareness.zoneA.tolerations }}
138+
{{- toYaml .Values.ingester.zoneAwareness.zoneA.tolerations | nindent 8 }}
139+
{{- else }}
140+
{{- toYaml .Values.ingester.tolerations | nindent 8 }}
141+
{{- end }}
142+
terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }}
143+
volumes:
144+
{{- include "cortex.configVolume" . | nindent 8 }}
145+
- name: runtime-config
146+
configMap:
147+
name: {{ template "cortex.fullname" . }}-runtime-config
148+
- name: storage
149+
emptyDir: {}
150+
{{- if .Values.ingester.extraVolumes }}
151+
{{- toYaml .Values.ingester.extraVolumes | nindent 8 }}
152+
{{- end }}
153+
{{- end -}}
154+
Lines changed: 154 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,154 @@
1+
{{- if and (not .Values.ingester.statefulSet.enabled) .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}}
2+
apiVersion: apps/v1
3+
kind: Deployment
4+
metadata:
5+
name: {{ include "cortex.ingesterFullname" . }}-zone-b
6+
namespace: {{ .Release.Namespace }}
7+
labels:
8+
{{- include "cortex.ingesterLabels" . | nindent 4 }}
9+
app.kubernetes.io/part-of: memberlist
10+
zone: b
11+
annotations:
12+
{{- toYaml .Values.ingester.zoneAwareness.zoneB.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }}
13+
spec:
14+
{{- if not .Values.ingester.autoscaling.enabled }}
15+
replicas: {{ .Values.ingester.zoneAwareness.zoneB.replicas | default .Values.ingester.replicas }}
16+
{{- end }}
17+
selector:
18+
matchLabels:
19+
{{- include "cortex.ingesterSelectorLabels" . | nindent 6 }}
20+
zone: b
21+
strategy:
22+
{{- toYaml .Values.ingester.strategy | nindent 4 }}
23+
template:
24+
metadata:
25+
labels:
26+
{{- include "cortex.ingesterLabels" . | nindent 8 }}
27+
app.kubernetes.io/part-of: memberlist
28+
zone: b
29+
{{- with .Values.ingester.podLabels }}
30+
{{- toYaml . | nindent 8 }}
31+
{{- end }}
32+
{{- with .Values.ingester.zoneAwareness.zoneB.podLabels }}
33+
{{- toYaml . | nindent 8 }}
34+
{{- end }}
35+
annotations:
36+
checksum/config: {{ include "cortex.configChecksum" . }}
37+
{{- with .Values.ingester.podAnnotations }}
38+
{{- toYaml . | nindent 8 }}
39+
{{- end }}
40+
{{- with .Values.ingester.zoneAwareness.zoneB.podAnnotations }}
41+
{{- toYaml . | nindent 8 }}
42+
{{- end }}
43+
spec:
44+
serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }}
45+
{{- if .Values.ingester.priorityClassName }}
46+
priorityClassName: {{ .Values.ingester.priorityClassName }}
47+
{{- end }}
48+
{{- if .Values.ingester.securityContext.enabled }}
49+
securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }}
50+
{{- end }}
51+
initContainers:
52+
{{- toYaml .Values.ingester.initContainers | nindent 8 }}
53+
{{- if .Values.image.pullSecrets }}
54+
imagePullSecrets:
55+
{{- range .Values.image.pullSecrets }}
56+
- name: {{ . }}
57+
{{- end }}
58+
{{- end }}
59+
containers:
60+
- name: ingester
61+
image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}"
62+
imagePullPolicy: {{ .Values.image.pullPolicy }}
63+
args:
64+
- "-target=ingester"
65+
- "-config.file=/etc/cortex/cortex.yaml"
66+
- "-ingester.availability-zone=zone-b"
67+
{{- include "cortex.memcached" . | nindent 12 }}
68+
{{- range $key, $value := .Values.ingester.extraArgs }}
69+
- "-{{ $key }}={{ $value }}"
70+
{{- end }}
71+
volumeMounts:
72+
{{- if .Values.ingester.extraVolumeMounts }}
73+
{{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }}
74+
{{- end }}
75+
- name: config
76+
mountPath: /etc/cortex
77+
- name: runtime-config
78+
mountPath: /etc/cortex-runtime-config
79+
- name: storage
80+
mountPath: "/data"
81+
{{- with .Values.ingester.persistentVolume.subPath }}
82+
subPath: {{ . }}
83+
{{- end }}
84+
ports:
85+
- name: http-metrics
86+
containerPort: {{ .Values.config.server.http_listen_port }}
87+
protocol: TCP
88+
- name: grpc
89+
containerPort: {{ .Values.config.server.grpc_listen_port }}
90+
protocol: TCP
91+
- name: gossip
92+
containerPort: {{ .Values.config.memberlist.bind_port }}
93+
protocol: TCP
94+
{{- if .Values.ingester.startupProbe }}
95+
startupProbe:
96+
{{- toYaml .Values.ingester.startupProbe | nindent 12 }}
97+
{{- end }}
98+
{{- if .Values.ingester.livenessProbe }}
99+
livenessProbe:
100+
{{- toYaml .Values.ingester.livenessProbe | nindent 12 }}
101+
{{- end }}
102+
readinessProbe:
103+
{{- toYaml .Values.ingester.readinessProbe | nindent 12 }}
104+
resources:
105+
{{- toYaml .Values.ingester.resources | nindent 12 }}
106+
{{- if .Values.ingester.containerSecurityContext.enabled }}
107+
securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }}
108+
{{- end }}
109+
{{- if .Values.ingester.env }}
110+
env:
111+
{{- toYaml .Values.ingester.env | nindent 12 }}
112+
{{- end }}
113+
{{- with .Values.ingester.lifecycle }}
114+
lifecycle:
115+
{{- toYaml . | nindent 12 }}
116+
{{- end }}
117+
{{- with .Values.ingester.extraContainers }}
118+
{{- toYaml . | nindent 8 }}
119+
{{- end }}
120+
nodeSelector:
121+
{{- if .Values.ingester.zoneAwareness.zoneB.nodeSelector }}
122+
{{- toYaml .Values.ingester.zoneAwareness.zoneB.nodeSelector | nindent 8 }}
123+
{{- else }}
124+
{{- toYaml .Values.ingester.nodeSelector | nindent 8 }}
125+
{{- end }}
126+
{{- if .Values.ingester.topologySpreadConstraints }}
127+
topologySpreadConstraints:
128+
{{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }}
129+
{{- end }}
130+
affinity:
131+
{{- if .Values.ingester.zoneAwareness.zoneB.extraAffinity }}
132+
{{- toYaml .Values.ingester.zoneAwareness.zoneB.extraAffinity | nindent 8 }}
133+
{{- else }}
134+
{{- toYaml .Values.ingester.affinity | nindent 8 }}
135+
{{- end }}
136+
tolerations:
137+
{{- if .Values.ingester.zoneAwareness.zoneB.tolerations }}
138+
{{- toYaml .Values.ingester.zoneAwareness.zoneB.tolerations | nindent 8 }}
139+
{{- else }}
140+
{{- toYaml .Values.ingester.tolerations | nindent 8 }}
141+
{{- end }}
142+
terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }}
143+
volumes:
144+
{{- include "cortex.configVolume" . | nindent 8 }}
145+
- name: runtime-config
146+
configMap:
147+
name: {{ template "cortex.fullname" . }}-runtime-config
148+
- name: storage
149+
emptyDir: {}
150+
{{- if .Values.ingester.extraVolumes }}
151+
{{- toYaml .Values.ingester.extraVolumes | nindent 8 }}
152+
{{- end }}
153+
{{- end -}}
154+

0 commit comments

Comments
 (0)