From 766e570829329b4b10841ef32a096fe4e2678506 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Wed, 20 May 2026 18:14:21 +0900 Subject: [PATCH 1/2] Add zone awareness support for ingester Signed-off-by: SungJin1212 --- CHANGELOG.md | 2 + templates/distributor/distributor-dep.yaml | 3 + templates/ingester/ingester-dep-zone-a.yaml | 154 +++++++++++++++ templates/ingester/ingester-dep-zone-b.yaml | 154 +++++++++++++++ templates/ingester/ingester-dep-zone-c.yaml | 154 +++++++++++++++ templates/ingester/ingester-dep.yaml | 2 +- templates/ingester/ingester-hpa-zone-a.yaml | 34 ++++ templates/ingester/ingester-hpa-zone-b.yaml | 34 ++++ templates/ingester/ingester-hpa-zone-c.yaml | 34 ++++ templates/ingester/ingester-hpa.yaml | 2 +- .../ingester/ingester-statefulset-zone-a.yaml | 183 +++++++++++++++++ .../ingester/ingester-statefulset-zone-b.yaml | 184 ++++++++++++++++++ .../ingester/ingester-statefulset-zone-c.yaml | 184 ++++++++++++++++++ templates/ingester/ingester-statefulset.yaml | 2 +- .../ingester-svc-headless-zone-a.yaml | 24 +++ .../ingester-svc-headless-zone-b.yaml | 25 +++ .../ingester-svc-headless-zone-c.yaml | 25 +++ templates/ingester/ingester-svc-headless.yaml | 2 +- templates/querier/querier-dep.yaml | 3 + templates/ruler/ruler-dep.yaml | 3 + values.yaml | 30 +++ 21 files changed, 1234 insertions(+), 4 deletions(-) create mode 100644 templates/ingester/ingester-dep-zone-a.yaml create mode 100644 templates/ingester/ingester-dep-zone-b.yaml create mode 100644 templates/ingester/ingester-dep-zone-c.yaml create mode 100644 templates/ingester/ingester-hpa-zone-a.yaml create mode 100644 templates/ingester/ingester-hpa-zone-b.yaml create mode 100644 templates/ingester/ingester-hpa-zone-c.yaml create mode 100644 templates/ingester/ingester-statefulset-zone-a.yaml create mode 100644 templates/ingester/ingester-statefulset-zone-b.yaml create mode 100644 templates/ingester/ingester-statefulset-zone-c.yaml create mode 100644 templates/ingester/ingester-svc-headless-zone-a.yaml create mode 100644 templates/ingester/ingester-svc-headless-zone-b.yaml create mode 100644 templates/ingester/ingester-svc-headless-zone-c.yaml diff --git a/CHANGELOG.md b/CHANGELOG.md index 5ea40c32..0debe947 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,8 @@ ## master / unreleased +* [FEATURE] Support zone awareness on Ingester. #632 + ## 3.3.0 / 2026-04-27 * [FEATURE] Add a parquet labels cache. #621 diff --git a/templates/distributor/distributor-dep.yaml b/templates/distributor/distributor-dep.yaml index 5470274e..4b907ce2 100644 --- a/templates/distributor/distributor-dep.yaml +++ b/templates/distributor/distributor-dep.yaml @@ -54,6 +54,9 @@ spec: args: - "-target=distributor" - "-config.file=/etc/cortex/cortex.yaml" + {{- if .Values.ingester.zoneAwareness.enabled }} + - -distributor.zone-awareness-enabled={{ not .Values.ingester.zoneAwareness.migration.enabled }} + {{- end }} {{- range $key, $value := .Values.distributor.extraArgs }} - "-{{ $key }}={{ $value }}" {{- end }} diff --git a/templates/ingester/ingester-dep-zone-a.yaml b/templates/ingester/ingester-dep-zone-a.yaml new file mode 100644 index 00000000..85b0cecf --- /dev/null +++ b/templates/ingester/ingester-dep-zone-a.yaml @@ -0,0 +1,154 @@ +{{- if and (not .Values.ingester.statefulSet.enabled) .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "cortex.ingesterFullname" . }}-zone-a + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + app.kubernetes.io/part-of: memberlist + zone: a + annotations: + {{- toYaml .Values.ingester.zoneAwareness.zoneA.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }} +spec: + {{- if not .Values.ingester.autoscaling.enabled }} + replicas: {{ .Values.ingester.zoneAwareness.zoneA.replicas | default .Values.ingester.replicas }} + {{- end }} + selector: + matchLabels: + {{- include "cortex.ingesterSelectorLabels" . | nindent 6 }} + zone: a + strategy: + {{- toYaml .Values.ingester.strategy | nindent 4 }} + template: + metadata: + labels: + {{- include "cortex.ingesterLabels" . | nindent 8 }} + app.kubernetes.io/part-of: memberlist + zone: a + {{- with .Values.ingester.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneA.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + annotations: + checksum/config: {{ include "cortex.configChecksum" . }} + {{- with .Values.ingester.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneA.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }} + {{- if .Values.ingester.priorityClassName }} + priorityClassName: {{ .Values.ingester.priorityClassName }} + {{- end }} + {{- if .Values.ingester.securityContext.enabled }} + securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + initContainers: + {{- toYaml .Values.ingester.initContainers | nindent 8 }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + containers: + - name: ingester + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-target=ingester" + - "-config.file=/etc/cortex/cortex.yaml" + - "-ingester.availability-zone=zone-a" + {{- include "cortex.memcached" . | nindent 12 }} + {{- range $key, $value := .Values.ingester.extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end }} + volumeMounts: + {{- if .Values.ingester.extraVolumeMounts }} + {{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }} + {{- end }} + - name: config + mountPath: /etc/cortex + - name: runtime-config + mountPath: /etc/cortex-runtime-config + - name: storage + mountPath: "/data" + {{- with .Values.ingester.persistentVolume.subPath }} + subPath: {{ . }} + {{- end }} + ports: + - name: http-metrics + containerPort: {{ .Values.config.server.http_listen_port }} + protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - name: gossip + containerPort: {{ .Values.config.memberlist.bind_port }} + protocol: TCP + {{- if .Values.ingester.startupProbe }} + startupProbe: + {{- toYaml .Values.ingester.startupProbe | nindent 12 }} + {{- end }} + {{- if .Values.ingester.livenessProbe }} + livenessProbe: + {{- toYaml .Values.ingester.livenessProbe | nindent 12 }} + {{- end }} + readinessProbe: + {{- toYaml .Values.ingester.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.ingester.resources | nindent 12 }} + {{- if .Values.ingester.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.ingester.env }} + env: + {{- toYaml .Values.ingester.env | nindent 12 }} + {{- end }} + {{- with .Values.ingester.lifecycle }} + lifecycle: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.ingester.extraContainers }} + {{- toYaml . | nindent 8 }} + {{- end }} + nodeSelector: + {{- if .Values.ingester.zoneAwareness.zoneA.nodeSelector }} + {{- toYaml .Values.ingester.zoneAwareness.zoneA.nodeSelector | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.ingester.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }} + {{- end }} + affinity: + {{- if .Values.ingester.zoneAwareness.zoneA.extraAffinity }} + {{- toYaml .Values.ingester.zoneAwareness.zoneA.extraAffinity | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.affinity | nindent 8 }} + {{- end }} + tolerations: + {{- if .Values.ingester.zoneAwareness.zoneA.tolerations }} + {{- toYaml .Values.ingester.zoneAwareness.zoneA.tolerations | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.tolerations | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} + volumes: + {{- include "cortex.configVolume" . | nindent 8 }} + - name: runtime-config + configMap: + name: {{ template "cortex.fullname" . }}-runtime-config + - name: storage + emptyDir: {} + {{- if .Values.ingester.extraVolumes }} + {{- toYaml .Values.ingester.extraVolumes | nindent 8 }} + {{- end }} +{{- end -}} + diff --git a/templates/ingester/ingester-dep-zone-b.yaml b/templates/ingester/ingester-dep-zone-b.yaml new file mode 100644 index 00000000..53d4e3a8 --- /dev/null +++ b/templates/ingester/ingester-dep-zone-b.yaml @@ -0,0 +1,154 @@ +{{- if and (not .Values.ingester.statefulSet.enabled) .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "cortex.ingesterFullname" . }}-zone-b + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + app.kubernetes.io/part-of: memberlist + zone: b + annotations: + {{- toYaml .Values.ingester.zoneAwareness.zoneB.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }} +spec: + {{- if not .Values.ingester.autoscaling.enabled }} + replicas: {{ .Values.ingester.zoneAwareness.zoneB.replicas | default .Values.ingester.replicas }} + {{- end }} + selector: + matchLabels: + {{- include "cortex.ingesterSelectorLabels" . | nindent 6 }} + zone: b + strategy: + {{- toYaml .Values.ingester.strategy | nindent 4 }} + template: + metadata: + labels: + {{- include "cortex.ingesterLabels" . | nindent 8 }} + app.kubernetes.io/part-of: memberlist + zone: b + {{- with .Values.ingester.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneB.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + annotations: + checksum/config: {{ include "cortex.configChecksum" . }} + {{- with .Values.ingester.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneB.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }} + {{- if .Values.ingester.priorityClassName }} + priorityClassName: {{ .Values.ingester.priorityClassName }} + {{- end }} + {{- if .Values.ingester.securityContext.enabled }} + securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + initContainers: + {{- toYaml .Values.ingester.initContainers | nindent 8 }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + containers: + - name: ingester + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-target=ingester" + - "-config.file=/etc/cortex/cortex.yaml" + - "-ingester.availability-zone=zone-b" + {{- include "cortex.memcached" . | nindent 12 }} + {{- range $key, $value := .Values.ingester.extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end }} + volumeMounts: + {{- if .Values.ingester.extraVolumeMounts }} + {{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }} + {{- end }} + - name: config + mountPath: /etc/cortex + - name: runtime-config + mountPath: /etc/cortex-runtime-config + - name: storage + mountPath: "/data" + {{- with .Values.ingester.persistentVolume.subPath }} + subPath: {{ . }} + {{- end }} + ports: + - name: http-metrics + containerPort: {{ .Values.config.server.http_listen_port }} + protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - name: gossip + containerPort: {{ .Values.config.memberlist.bind_port }} + protocol: TCP + {{- if .Values.ingester.startupProbe }} + startupProbe: + {{- toYaml .Values.ingester.startupProbe | nindent 12 }} + {{- end }} + {{- if .Values.ingester.livenessProbe }} + livenessProbe: + {{- toYaml .Values.ingester.livenessProbe | nindent 12 }} + {{- end }} + readinessProbe: + {{- toYaml .Values.ingester.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.ingester.resources | nindent 12 }} + {{- if .Values.ingester.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.ingester.env }} + env: + {{- toYaml .Values.ingester.env | nindent 12 }} + {{- end }} + {{- with .Values.ingester.lifecycle }} + lifecycle: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.ingester.extraContainers }} + {{- toYaml . | nindent 8 }} + {{- end }} + nodeSelector: + {{- if .Values.ingester.zoneAwareness.zoneB.nodeSelector }} + {{- toYaml .Values.ingester.zoneAwareness.zoneB.nodeSelector | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.ingester.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }} + {{- end }} + affinity: + {{- if .Values.ingester.zoneAwareness.zoneB.extraAffinity }} + {{- toYaml .Values.ingester.zoneAwareness.zoneB.extraAffinity | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.affinity | nindent 8 }} + {{- end }} + tolerations: + {{- if .Values.ingester.zoneAwareness.zoneB.tolerations }} + {{- toYaml .Values.ingester.zoneAwareness.zoneB.tolerations | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.tolerations | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} + volumes: + {{- include "cortex.configVolume" . | nindent 8 }} + - name: runtime-config + configMap: + name: {{ template "cortex.fullname" . }}-runtime-config + - name: storage + emptyDir: {} + {{- if .Values.ingester.extraVolumes }} + {{- toYaml .Values.ingester.extraVolumes | nindent 8 }} + {{- end }} +{{- end -}} + diff --git a/templates/ingester/ingester-dep-zone-c.yaml b/templates/ingester/ingester-dep-zone-c.yaml new file mode 100644 index 00000000..6d5409a4 --- /dev/null +++ b/templates/ingester/ingester-dep-zone-c.yaml @@ -0,0 +1,154 @@ +{{- if and (not .Values.ingester.statefulSet.enabled) .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "cortex.ingesterFullname" . }}-zone-c + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + app.kubernetes.io/part-of: memberlist + zone: c + annotations: + {{- toYaml .Values.ingester.zoneAwareness.zoneC.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }} +spec: + {{- if not .Values.ingester.autoscaling.enabled }} + replicas: {{ .Values.ingester.zoneAwareness.zoneC.replicas | default .Values.ingester.replicas }} + {{- end }} + selector: + matchLabels: + {{- include "cortex.ingesterSelectorLabels" . | nindent 6 }} + zone: c + strategy: + {{- toYaml .Values.ingester.strategy | nindent 4 }} + template: + metadata: + labels: + {{- include "cortex.ingesterLabels" . | nindent 8 }} + app.kubernetes.io/part-of: memberlist + zone: c + {{- with .Values.ingester.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneC.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + annotations: + checksum/config: {{ include "cortex.configChecksum" . }} + {{- with .Values.ingester.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneC.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }} + {{- if .Values.ingester.priorityClassName }} + priorityClassName: {{ .Values.ingester.priorityClassName }} + {{- end }} + {{- if .Values.ingester.securityContext.enabled }} + securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + initContainers: + {{- toYaml .Values.ingester.initContainers | nindent 8 }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + containers: + - name: ingester + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-target=ingester" + - "-config.file=/etc/cortex/cortex.yaml" + - "-ingester.availability-zone=zone-c" + {{- include "cortex.memcached" . | nindent 12 }} + {{- range $key, $value := .Values.ingester.extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end }} + volumeMounts: + {{- if .Values.ingester.extraVolumeMounts }} + {{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }} + {{- end }} + - name: config + mountPath: /etc/cortex + - name: runtime-config + mountPath: /etc/cortex-runtime-config + - name: storage + mountPath: "/data" + {{- with .Values.ingester.persistentVolume.subPath }} + subPath: {{ . }} + {{- end }} + ports: + - name: http-metrics + containerPort: {{ .Values.config.server.http_listen_port }} + protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - name: gossip + containerPort: {{ .Values.config.memberlist.bind_port }} + protocol: TCP + {{- if .Values.ingester.startupProbe }} + startupProbe: + {{- toYaml .Values.ingester.startupProbe | nindent 12 }} + {{- end }} + {{- if .Values.ingester.livenessProbe }} + livenessProbe: + {{- toYaml .Values.ingester.livenessProbe | nindent 12 }} + {{- end }} + readinessProbe: + {{- toYaml .Values.ingester.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.ingester.resources | nindent 12 }} + {{- if .Values.ingester.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.ingester.env }} + env: + {{- toYaml .Values.ingester.env | nindent 12 }} + {{- end }} + {{- with .Values.ingester.lifecycle }} + lifecycle: + {{- toYaml . | nindent 12 }} + {{- end }} + {{- with .Values.ingester.extraContainers }} + {{- toYaml . | nindent 8 }} + {{- end }} + nodeSelector: + {{- if .Values.ingester.zoneAwareness.zoneC.nodeSelector }} + {{- toYaml .Values.ingester.zoneAwareness.zoneC.nodeSelector | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.ingester.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }} + {{- end }} + affinity: + {{- if .Values.ingester.zoneAwareness.zoneC.extraAffinity }} + {{- toYaml .Values.ingester.zoneAwareness.zoneC.extraAffinity | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.affinity | nindent 8 }} + {{- end }} + tolerations: + {{- if .Values.ingester.zoneAwareness.zoneC.tolerations }} + {{- toYaml .Values.ingester.zoneAwareness.zoneC.tolerations | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.tolerations | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} + volumes: + {{- include "cortex.configVolume" . | nindent 8 }} + - name: runtime-config + configMap: + name: {{ template "cortex.fullname" . }}-runtime-config + - name: storage + emptyDir: {} + {{- if .Values.ingester.extraVolumes }} + {{- toYaml .Values.ingester.extraVolumes | nindent 8 }} + {{- end }} +{{- end -}} + diff --git a/templates/ingester/ingester-dep.yaml b/templates/ingester/ingester-dep.yaml index 7d270101..9a816f0c 100644 --- a/templates/ingester/ingester-dep.yaml +++ b/templates/ingester/ingester-dep.yaml @@ -1,4 +1,4 @@ -{{- if and (not .Values.ingester.statefulSet.enabled) .Values.ingester.enabled -}} +{{- if and (not .Values.ingester.statefulSet.enabled) .Values.ingester.enabled (or (not .Values.ingester.zoneAwareness.enabled) .Values.ingester.zoneAwareness.migration.enabled) -}} apiVersion: apps/v1 kind: Deployment metadata: diff --git a/templates/ingester/ingester-hpa-zone-a.yaml b/templates/ingester/ingester-hpa-zone-a.yaml new file mode 100644 index 00000000..3a67f195 --- /dev/null +++ b/templates/ingester/ingester-hpa-zone-a.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled .Values.ingester.autoscaling.enabled -}} +{{- with .Values.ingester.autoscaling -}} +apiVersion: {{ include "cortex.hpaVersion" $ }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "cortex.ingesterFullname" $ }}-zone-a + namespace: {{ $.Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" $ | nindent 4 }} + zone: a +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: {{ if $.Values.ingester.statefulSet.enabled }}StatefulSet{{ else }}Deployment{{ end }} + name: {{ include "cortex.ingesterFullname" $ }}-zone-a + minReplicas: {{ .minReplicas }} + maxReplicas: {{ .maxReplicas }} + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .targetMemoryUtilizationPercentage }} + {{- with .extraMetrics }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} +{{- end }} + diff --git a/templates/ingester/ingester-hpa-zone-b.yaml b/templates/ingester/ingester-hpa-zone-b.yaml new file mode 100644 index 00000000..0a7276d0 --- /dev/null +++ b/templates/ingester/ingester-hpa-zone-b.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled .Values.ingester.autoscaling.enabled -}} +{{- with .Values.ingester.autoscaling -}} +apiVersion: {{ include "cortex.hpaVersion" $ }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "cortex.ingesterFullname" $ }}-zone-b + namespace: {{ $.Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" $ | nindent 4 }} + zone: b +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: {{ if $.Values.ingester.statefulSet.enabled }}StatefulSet{{ else }}Deployment{{ end }} + name: {{ include "cortex.ingesterFullname" $ }}-zone-b + minReplicas: {{ .minReplicas }} + maxReplicas: {{ .maxReplicas }} + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .targetMemoryUtilizationPercentage }} + {{- with .extraMetrics }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} +{{- end }} + diff --git a/templates/ingester/ingester-hpa-zone-c.yaml b/templates/ingester/ingester-hpa-zone-c.yaml new file mode 100644 index 00000000..dfa50e50 --- /dev/null +++ b/templates/ingester/ingester-hpa-zone-c.yaml @@ -0,0 +1,34 @@ +{{- if and .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled .Values.ingester.autoscaling.enabled -}} +{{- with .Values.ingester.autoscaling -}} +apiVersion: {{ include "cortex.hpaVersion" $ }} +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "cortex.ingesterFullname" $ }}-zone-c + namespace: {{ $.Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" $ | nindent 4 }} + zone: c +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: {{ if $.Values.ingester.statefulSet.enabled }}StatefulSet{{ else }}Deployment{{ end }} + name: {{ include "cortex.ingesterFullname" $ }}-zone-c + minReplicas: {{ .minReplicas }} + maxReplicas: {{ .maxReplicas }} + metrics: + - type: Resource + resource: + name: memory + target: + type: Utilization + averageUtilization: {{ .targetMemoryUtilizationPercentage }} + {{- with .extraMetrics }} + {{- toYaml . | nindent 4 }} + {{- end }} + {{- with .behavior }} + behavior: + {{- toYaml . | nindent 4 }} + {{- end }} +{{- end }} +{{- end }} + diff --git a/templates/ingester/ingester-hpa.yaml b/templates/ingester/ingester-hpa.yaml index 1bc6e6a5..a0d4a58a 100644 --- a/templates/ingester/ingester-hpa.yaml +++ b/templates/ingester/ingester-hpa.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.ingester.enabled .Values.ingester.autoscaling.enabled -}} +{{- if and .Values.ingester.enabled .Values.ingester.autoscaling.enabled (or (not .Values.ingester.zoneAwareness.enabled) .Values.ingester.zoneAwareness.migration.enabled) -}} {{- with .Values.ingester.autoscaling -}} apiVersion: {{ include "cortex.hpaVersion" $ }} kind: HorizontalPodAutoscaler diff --git a/templates/ingester/ingester-statefulset-zone-a.yaml b/templates/ingester/ingester-statefulset-zone-a.yaml new file mode 100644 index 00000000..bbf7a514 --- /dev/null +++ b/templates/ingester/ingester-statefulset-zone-a.yaml @@ -0,0 +1,183 @@ +{{- if and .Values.ingester.enabled .Values.ingester.statefulSet.enabled .Values.ingester.zoneAwareness.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "cortex.ingesterFullname" . }}-zone-a + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + app.kubernetes.io/part-of: memberlist + zone: a + annotations: + {{- toYaml .Values.ingester.zoneAwareness.zoneA.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }} +spec: + replicas: {{ .Values.ingester.zoneAwareness.zoneA.replicas | default .Values.ingester.replicas }} + podManagementPolicy: Parallel + selector: + matchLabels: + {{- include "cortex.ingesterSelectorLabels" . | nindent 6 }} + zone: a + updateStrategy: + {{- toYaml .Values.ingester.statefulStrategy | nindent 4 }} + serviceName: {{ include "cortex.ingesterFullname" . }}-headless-zone-a + {{- if .Values.ingester.persistentVolume.enabled }} + {{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.ingester.persistentVolume.retentionPolicy }} + persistentVolumeClaimRetentionPolicy: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + volumeClaimTemplates: + - metadata: + name: storage + {{- if .Values.ingester.persistentVolume.annotations }} + annotations: + {{ toYaml .Values.ingester.persistentVolume.annotations | nindent 10 }} + {{- end }} + spec: + {{- if .Values.ingester.persistentVolume.storageClass }} + {{- if (eq "-" .Values.ingester.persistentVolume.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.ingester.persistentVolume.storageClass }}" + {{- end }} + {{- end }} + accessModes: + {{ toYaml .Values.ingester.persistentVolume.accessModes | nindent 10 }} + resources: + requests: + storage: "{{ .Values.ingester.persistentVolume.size }}" + {{- end }} + template: + metadata: + labels: + {{- include "cortex.ingesterLabels" . | nindent 8 }} + app.kubernetes.io/part-of: memberlist + zone: a + {{- with .Values.ingester.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneA.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + annotations: + checksum/config: {{ include "cortex.configChecksum" . }} + {{- with .Values.ingester.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneA.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }} + {{- if .Values.ingester.priorityClassName }} + priorityClassName: {{ .Values.ingester.priorityClassName }} + {{- end }} + {{- if .Values.ingester.securityContext.enabled }} + securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + initContainers: + {{- toYaml .Values.ingester.initContainers | nindent 8 }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + nodeSelector: + {{- if .Values.ingester.zoneAwareness.zoneA.nodeSelector }} + {{- toYaml .Values.ingester.zoneAwareness.zoneA.nodeSelector | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.ingester.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }} + {{- end }} + affinity: + {{- if .Values.ingester.zoneAwareness.zoneA.extraAffinity }} + {{- toYaml .Values.ingester.zoneAwareness.zoneA.extraAffinity | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.affinity | nindent 8 }} + {{- end }} + tolerations: + {{- if .Values.ingester.zoneAwareness.zoneA.tolerations }} + {{- toYaml .Values.ingester.zoneAwareness.zoneA.tolerations | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.tolerations | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} + volumes: + {{- include "cortex.configVolume" . | nindent 8 }} + - name: runtime-config + configMap: + name: {{ template "cortex.fullname" . }}-runtime-config + {{- if not .Values.ingester.persistentVolume.enabled }} + - name: storage + emptyDir: {} + {{- end }} + {{- if .Values.ingester.extraVolumes }} + {{- toYaml .Values.ingester.extraVolumes | nindent 8 }} + {{- end }} + containers: + {{- if .Values.ingester.extraContainers }} + {{- toYaml .Values.ingester.extraContainers | nindent 8 }} + {{- end }} + - name: ingester + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-target=ingester" + - "-config.file=/etc/cortex/cortex.yaml" + - "-ingester.availability-zone=zone-a" + {{- include "cortex.memcached" . | nindent 12 }} + {{- range $key, $value := .Values.ingester.extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end }} + volumeMounts: + {{- if .Values.ingester.extraVolumeMounts }} + {{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }} + {{- end }} + - name: config + mountPath: /etc/cortex + - name: runtime-config + mountPath: /etc/cortex-runtime-config + - name: storage + mountPath: "/data" + {{- with .Values.ingester.persistentVolume.subPath }} + subPath: {{ . }} + {{- end }} + ports: + - name: http-metrics + containerPort: {{ .Values.config.server.http_listen_port }} + protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - name: gossip + containerPort: {{ .Values.config.memberlist.bind_port }} + protocol: TCP + {{- if .Values.ingester.startupProbe }} + startupProbe: + {{- toYaml .Values.ingester.startupProbe | nindent 12 }} + {{- end }} + {{- if .Values.ingester.livenessProbe }} + livenessProbe: + {{- toYaml .Values.ingester.livenessProbe | nindent 12 }} + {{- end }} + readinessProbe: + {{- toYaml .Values.ingester.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.ingester.resources | nindent 12 }} + {{- if .Values.ingester.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.ingester.env }} + env: + {{- toYaml .Values.ingester.env | nindent 12 }} + {{- end }} + {{- with .Values.ingester.lifecycle }} + lifecycle: + {{- toYaml . | nindent 12 }} + {{- end }} +{{- end }} diff --git a/templates/ingester/ingester-statefulset-zone-b.yaml b/templates/ingester/ingester-statefulset-zone-b.yaml new file mode 100644 index 00000000..2bd901c4 --- /dev/null +++ b/templates/ingester/ingester-statefulset-zone-b.yaml @@ -0,0 +1,184 @@ +{{- if and .Values.ingester.enabled .Values.ingester.statefulSet.enabled .Values.ingester.zoneAwareness.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "cortex.ingesterFullname" . }}-zone-b + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + app.kubernetes.io/part-of: memberlist + zone: b + annotations: + {{- toYaml .Values.ingester.zoneAwareness.zoneB.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }} +spec: + replicas: {{ .Values.ingester.zoneAwareness.zoneB.replicas | default .Values.ingester.replicas }} + podManagementPolicy: Parallel + selector: + matchLabels: + {{- include "cortex.ingesterSelectorLabels" . | nindent 6 }} + zone: b + updateStrategy: + {{- toYaml .Values.ingester.statefulStrategy | nindent 4 }} + serviceName: {{ include "cortex.ingesterFullname" . }}-headless-zone-b + {{- if .Values.ingester.persistentVolume.enabled }} + {{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.ingester.persistentVolume.retentionPolicy }} + persistentVolumeClaimRetentionPolicy: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + volumeClaimTemplates: + - metadata: + name: storage + {{- if .Values.ingester.persistentVolume.annotations }} + annotations: + {{ toYaml .Values.ingester.persistentVolume.annotations | nindent 10 }} + {{- end }} + spec: + {{- if .Values.ingester.persistentVolume.storageClass }} + {{- if (eq "-" .Values.ingester.persistentVolume.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.ingester.persistentVolume.storageClass }}" + {{- end }} + {{- end }} + accessModes: + {{ toYaml .Values.ingester.persistentVolume.accessModes | nindent 10 }} + resources: + requests: + storage: "{{ .Values.ingester.persistentVolume.size }}" + {{- end }} + template: + metadata: + labels: + {{- include "cortex.ingesterLabels" . | nindent 8 }} + app.kubernetes.io/part-of: memberlist + zone: b + {{- with .Values.ingester.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneB.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + annotations: + checksum/config: {{ include "cortex.configChecksum" . }} + {{- with .Values.ingester.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneB.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }} + {{- if .Values.ingester.priorityClassName }} + priorityClassName: {{ .Values.ingester.priorityClassName }} + {{- end }} + {{- if .Values.ingester.securityContext.enabled }} + securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + initContainers: + {{- toYaml .Values.ingester.initContainers | nindent 8 }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + nodeSelector: + {{- if .Values.ingester.zoneAwareness.zoneB.nodeSelector }} + {{- toYaml .Values.ingester.zoneAwareness.zoneB.nodeSelector | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.ingester.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }} + {{- end }} + affinity: + {{- if .Values.ingester.zoneAwareness.zoneB.extraAffinity }} + {{- toYaml .Values.ingester.zoneAwareness.zoneB.extraAffinity | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.affinity | nindent 8 }} + {{- end }} + tolerations: + {{- if .Values.ingester.zoneAwareness.zoneB.tolerations }} + {{- toYaml .Values.ingester.zoneAwareness.zoneB.tolerations | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.tolerations | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} + volumes: + {{- include "cortex.configVolume" . | nindent 8 }} + - name: runtime-config + configMap: + name: {{ template "cortex.fullname" . }}-runtime-config + {{- if not .Values.ingester.persistentVolume.enabled }} + - name: storage + emptyDir: {} + {{- end }} + {{- if .Values.ingester.extraVolumes }} + {{- toYaml .Values.ingester.extraVolumes | nindent 8 }} + {{- end }} + containers: + {{- if .Values.ingester.extraContainers }} + {{- toYaml .Values.ingester.extraContainers | nindent 8 }} + {{- end }} + - name: ingester + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-target=ingester" + - "-config.file=/etc/cortex/cortex.yaml" + - "-ingester.availability-zone=zone-b" + {{- include "cortex.memcached" . | nindent 12 }} + {{- range $key, $value := .Values.ingester.extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end }} + volumeMounts: + {{- if .Values.ingester.extraVolumeMounts }} + {{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }} + {{- end }} + - name: config + mountPath: /etc/cortex + - name: runtime-config + mountPath: /etc/cortex-runtime-config + - name: storage + mountPath: "/data" + {{- with .Values.ingester.persistentVolume.subPath }} + subPath: {{ . }} + {{- end }} + ports: + - name: http-metrics + containerPort: {{ .Values.config.server.http_listen_port }} + protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - name: gossip + containerPort: {{ .Values.config.memberlist.bind_port }} + protocol: TCP + {{- if .Values.ingester.startupProbe }} + startupProbe: + {{- toYaml .Values.ingester.startupProbe | nindent 12 }} + {{- end }} + {{- if .Values.ingester.livenessProbe }} + livenessProbe: + {{- toYaml .Values.ingester.livenessProbe | nindent 12 }} + {{- end }} + readinessProbe: + {{- toYaml .Values.ingester.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.ingester.resources | nindent 12 }} + {{- if .Values.ingester.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.ingester.env }} + env: + {{- toYaml .Values.ingester.env | nindent 12 }} + {{- end }} + {{- with .Values.ingester.lifecycle }} + lifecycle: + {{- toYaml . | nindent 12 }} + {{- end }} +{{- end }} + diff --git a/templates/ingester/ingester-statefulset-zone-c.yaml b/templates/ingester/ingester-statefulset-zone-c.yaml new file mode 100644 index 00000000..429dbe89 --- /dev/null +++ b/templates/ingester/ingester-statefulset-zone-c.yaml @@ -0,0 +1,184 @@ +{{- if and .Values.ingester.enabled .Values.ingester.statefulSet.enabled .Values.ingester.zoneAwareness.enabled }} +apiVersion: apps/v1 +kind: StatefulSet +metadata: + name: {{ include "cortex.ingesterFullname" . }}-zone-c + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + app.kubernetes.io/part-of: memberlist + zone: c + annotations: + {{- toYaml .Values.ingester.zoneAwareness.zoneC.annotations | default (toYaml .Values.ingester.annotations) | nindent 4 }} +spec: + replicas: {{ .Values.ingester.zoneAwareness.zoneC.replicas | default .Values.ingester.replicas }} + podManagementPolicy: Parallel + selector: + matchLabels: + {{- include "cortex.ingesterSelectorLabels" . | nindent 6 }} + zone: c + updateStrategy: + {{- toYaml .Values.ingester.statefulStrategy | nindent 4 }} + serviceName: {{ include "cortex.ingesterFullname" . }}-headless-zone-c + {{- if .Values.ingester.persistentVolume.enabled }} + {{- if semverCompare ">=1.23-0" .Capabilities.KubeVersion.Version }} + {{- with .Values.ingester.persistentVolume.retentionPolicy }} + persistentVolumeClaimRetentionPolicy: + {{- toYaml . | nindent 4 }} + {{- end }} + {{- end }} + volumeClaimTemplates: + - metadata: + name: storage + {{- if .Values.ingester.persistentVolume.annotations }} + annotations: + {{ toYaml .Values.ingester.persistentVolume.annotations | nindent 10 }} + {{- end }} + spec: + {{- if .Values.ingester.persistentVolume.storageClass }} + {{- if (eq "-" .Values.ingester.persistentVolume.storageClass) }} + storageClassName: "" + {{- else }} + storageClassName: "{{ .Values.ingester.persistentVolume.storageClass }}" + {{- end }} + {{- end }} + accessModes: + {{ toYaml .Values.ingester.persistentVolume.accessModes | nindent 10 }} + resources: + requests: + storage: "{{ .Values.ingester.persistentVolume.size }}" + {{- end }} + template: + metadata: + labels: + {{- include "cortex.ingesterLabels" . | nindent 8 }} + app.kubernetes.io/part-of: memberlist + zone: c + {{- with .Values.ingester.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneC.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + annotations: + checksum/config: {{ include "cortex.configChecksum" . }} + {{- with .Values.ingester.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.ingester.zoneAwareness.zoneC.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ .Values.ingester.serviceAccount.name | default (include "cortex.serviceAccountName" .) }} + {{- if .Values.ingester.priorityClassName }} + priorityClassName: {{ .Values.ingester.priorityClassName }} + {{- end }} + {{- if .Values.ingester.securityContext.enabled }} + securityContext: {{- omit .Values.ingester.securityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + initContainers: + {{- toYaml .Values.ingester.initContainers | nindent 8 }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + nodeSelector: + {{- if .Values.ingester.zoneAwareness.zoneC.nodeSelector }} + {{- toYaml .Values.ingester.zoneAwareness.zoneC.nodeSelector | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.nodeSelector | nindent 8 }} + {{- end }} + {{- if .Values.ingester.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.ingester.topologySpreadConstraints | nindent 8 }} + {{- end }} + affinity: + {{- if .Values.ingester.zoneAwareness.zoneC.extraAffinity }} + {{- toYaml .Values.ingester.zoneAwareness.zoneC.extraAffinity | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.affinity | nindent 8 }} + {{- end }} + tolerations: + {{- if .Values.ingester.zoneAwareness.zoneC.tolerations }} + {{- toYaml .Values.ingester.zoneAwareness.zoneC.tolerations | nindent 8 }} + {{- else }} + {{- toYaml .Values.ingester.tolerations | nindent 8 }} + {{- end }} + terminationGracePeriodSeconds: {{ .Values.ingester.terminationGracePeriodSeconds }} + volumes: + {{- include "cortex.configVolume" . | nindent 8 }} + - name: runtime-config + configMap: + name: {{ template "cortex.fullname" . }}-runtime-config + {{- if not .Values.ingester.persistentVolume.enabled }} + - name: storage + emptyDir: {} + {{- end }} + {{- if .Values.ingester.extraVolumes }} + {{- toYaml .Values.ingester.extraVolumes | nindent 8 }} + {{- end }} + containers: + {{- if .Values.ingester.extraContainers }} + {{- toYaml .Values.ingester.extraContainers | nindent 8 }} + {{- end }} + - name: ingester + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-target=ingester" + - "-config.file=/etc/cortex/cortex.yaml" + - "-ingester.availability-zone=zone-c" + {{- include "cortex.memcached" . | nindent 12 }} + {{- range $key, $value := .Values.ingester.extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end }} + volumeMounts: + {{- if .Values.ingester.extraVolumeMounts }} + {{- toYaml .Values.ingester.extraVolumeMounts | nindent 12 }} + {{- end }} + - name: config + mountPath: /etc/cortex + - name: runtime-config + mountPath: /etc/cortex-runtime-config + - name: storage + mountPath: "/data" + {{- with .Values.ingester.persistentVolume.subPath }} + subPath: {{ . }} + {{- end }} + ports: + - name: http-metrics + containerPort: {{ .Values.config.server.http_listen_port }} + protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - name: gossip + containerPort: {{ .Values.config.memberlist.bind_port }} + protocol: TCP + {{- if .Values.ingester.startupProbe }} + startupProbe: + {{- toYaml .Values.ingester.startupProbe | nindent 12 }} + {{- end }} + {{- if .Values.ingester.livenessProbe }} + livenessProbe: + {{- toYaml .Values.ingester.livenessProbe | nindent 12 }} + {{- end }} + readinessProbe: + {{- toYaml .Values.ingester.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.ingester.resources | nindent 12 }} + {{- if .Values.ingester.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.ingester.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.ingester.env }} + env: + {{- toYaml .Values.ingester.env | nindent 12 }} + {{- end }} + {{- with .Values.ingester.lifecycle }} + lifecycle: + {{- toYaml . | nindent 12 }} + {{- end }} +{{- end }} + diff --git a/templates/ingester/ingester-statefulset.yaml b/templates/ingester/ingester-statefulset.yaml index b6d37ae2..08690b5b 100644 --- a/templates/ingester/ingester-statefulset.yaml +++ b/templates/ingester/ingester-statefulset.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.ingester.statefulSet.enabled .Values.ingester.enabled -}} +{{- if and .Values.ingester.statefulSet.enabled .Values.ingester.enabled (or (not .Values.ingester.zoneAwareness.enabled) .Values.ingester.zoneAwareness.migration.enabled) -}} apiVersion: apps/v1 kind: StatefulSet metadata: diff --git a/templates/ingester/ingester-svc-headless-zone-a.yaml b/templates/ingester/ingester-svc-headless-zone-a.yaml new file mode 100644 index 00000000..10cb72c6 --- /dev/null +++ b/templates/ingester/ingester-svc-headless-zone-a.yaml @@ -0,0 +1,24 @@ +{{- if and .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "cortex.ingesterFullname" . }}-headless-zone-a + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + {{- with .Values.ingester.service.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + annotations: + {{- toYaml .Values.ingester.service.annotations | nindent 4 }} +spec: + type: ClusterIP + clusterIP: None + ports: + - port: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + name: grpc + targetPort: grpc + selector: + {{- include "cortex.ingesterSelectorLabels" . | nindent 4 }} +{{- end }} \ No newline at end of file diff --git a/templates/ingester/ingester-svc-headless-zone-b.yaml b/templates/ingester/ingester-svc-headless-zone-b.yaml new file mode 100644 index 00000000..daca4281 --- /dev/null +++ b/templates/ingester/ingester-svc-headless-zone-b.yaml @@ -0,0 +1,25 @@ +{{- if and .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "cortex.ingesterFullname" . }}-headless-zone-b + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + {{- with .Values.ingester.service.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + annotations: + {{- toYaml .Values.ingester.service.annotations | nindent 4 }} +spec: + type: ClusterIP + clusterIP: None + ports: + - port: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + name: grpc + targetPort: grpc + selector: + {{- include "cortex.ingesterSelectorLabels" . | nindent 4 }} +{{- end }} + diff --git a/templates/ingester/ingester-svc-headless-zone-c.yaml b/templates/ingester/ingester-svc-headless-zone-c.yaml new file mode 100644 index 00000000..c67caaf5 --- /dev/null +++ b/templates/ingester/ingester-svc-headless-zone-c.yaml @@ -0,0 +1,25 @@ +{{- if and .Values.ingester.enabled .Values.ingester.zoneAwareness.enabled -}} +apiVersion: v1 +kind: Service +metadata: + name: {{ include "cortex.ingesterFullname" . }}-headless-zone-c + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.ingesterLabels" . | nindent 4 }} + {{- with .Values.ingester.service.labels }} + {{- toYaml . | nindent 4 }} + {{- end }} + annotations: + {{- toYaml .Values.ingester.service.annotations | nindent 4 }} +spec: + type: ClusterIP + clusterIP: None + ports: + - port: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + name: grpc + targetPort: grpc + selector: + {{- include "cortex.ingesterSelectorLabels" . | nindent 4 }} +{{- end }} + diff --git a/templates/ingester/ingester-svc-headless.yaml b/templates/ingester/ingester-svc-headless.yaml index 0f698179..cc7ee924 100644 --- a/templates/ingester/ingester-svc-headless.yaml +++ b/templates/ingester/ingester-svc-headless.yaml @@ -1,4 +1,4 @@ -{{- if .Values.ingester.enabled -}} +{{- if and .Values.ingester.enabled (or (not .Values.ingester.zoneAwareness.enabled) .Values.ingester.zoneAwareness.migration.enabled) -}} apiVersion: v1 kind: Service metadata: diff --git a/templates/querier/querier-dep.yaml b/templates/querier/querier-dep.yaml index 438a5ffd..f24fc9e0 100644 --- a/templates/querier/querier-dep.yaml +++ b/templates/querier/querier-dep.yaml @@ -59,6 +59,9 @@ spec: - "-querier.frontend-address={{ template "cortex.queryFrontendFullname" . }}-headless.{{ .Release.Namespace }}.svc.{{ .Values.clusterDomain }}:{{ .Values.config.server.grpc_listen_port }}" {{- end }} {{- include "cortex.memcached" . | nindent 12}} + {{- if .Values.ingester.zoneAwareness.enabled }} + - -ingester.zone-awareness-enabled={{ not .Values.ingester.zoneAwareness.migration.enabled }} + {{- end }} {{- range $key, $value := .Values.querier.extraArgs }} - "-{{ $key }}={{ $value }}" {{- end }} diff --git a/templates/ruler/ruler-dep.yaml b/templates/ruler/ruler-dep.yaml index e6c68d6f..53253b28 100644 --- a/templates/ruler/ruler-dep.yaml +++ b/templates/ruler/ruler-dep.yaml @@ -129,6 +129,9 @@ spec: {{- end }} {{- end }} {{- include "cortex.memcached" . | nindent 12}} + {{- if .Values.ingester.zoneAwareness.enabled }} + - -ingester.zone-awareness-enabled={{ not .Values.ingester.zoneAwareness.migration.enabled }} + {{- end }} {{- range $key, $value := .Values.ruler.extraArgs }} - "-{{ $key }}={{ $value }}" {{- end }} diff --git a/values.yaml b/values.yaml index d0311391..7e72b79b 100644 --- a/values.yaml +++ b/values.yaml @@ -607,6 +607,36 @@ ingester: extraPorts: [] env: [] + zoneAwareness: + enabled: false + migration: + enabled: false + zoneA: + replicas: 1 + nodeSelector: {} + extraAffinity: {} + tolerations: [] + annotations: {} + podAnnotations: {} + podLabels: {} + zoneB: + replicas: 1 + nodeSelector: {} + extraAffinity: {} + tolerations: [] + annotations: {} + podAnnotations: {} + podLabels: {} + zoneC: + replicas: 1 + nodeSelector: {} + extraAffinity: {} + tolerations: [] + annotations: {} + podAnnotations: {} + podLabels: {} + + ruler: enabled: true replicas: 1 From 27d36ad94206097cff0bb286ad7fcd13c40200f2 Mon Sep 17 00:00:00 2001 From: SungJin1212 Date: Wed, 20 May 2026 18:15:23 +0900 Subject: [PATCH 2/2] readme Signed-off-by: SungJin1212 --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index d52ebad7..d5e2e504 100644 --- a/README.md +++ b/README.md @@ -382,6 +382,29 @@ Kubernetes: `^1.19.0-0` | ingester.​terminationGracePeriodSeconds | int | `240` | | | ingester.​tolerations | list | `[]` | | | ingester.​topologySpreadConstraints | list | `[]` | | +| ingester.​zoneAwareness.​enabled | bool | `false` | | +| ingester.​zoneAwareness.​migration.​enabled | bool | `false` | | +| ingester.​zoneAwareness.​zoneA.​annotations | object | `{}` | | +| ingester.​zoneAwareness.​zoneA.​extraAffinity | object | `{}` | | +| ingester.​zoneAwareness.​zoneA.​nodeSelector | object | `{}` | | +| ingester.​zoneAwareness.​zoneA.​podAnnotations | object | `{}` | | +| ingester.​zoneAwareness.​zoneA.​podLabels | object | `{}` | | +| ingester.​zoneAwareness.​zoneA.​replicas | int | `1` | | +| ingester.​zoneAwareness.​zoneA.​tolerations | list | `[]` | | +| ingester.​zoneAwareness.​zoneB.​annotations | object | `{}` | | +| ingester.​zoneAwareness.​zoneB.​extraAffinity | object | `{}` | | +| ingester.​zoneAwareness.​zoneB.​nodeSelector | object | `{}` | | +| ingester.​zoneAwareness.​zoneB.​podAnnotations | object | `{}` | | +| ingester.​zoneAwareness.​zoneB.​podLabels | object | `{}` | | +| ingester.​zoneAwareness.​zoneB.​replicas | int | `1` | | +| ingester.​zoneAwareness.​zoneB.​tolerations | list | `[]` | | +| ingester.​zoneAwareness.​zoneC.​annotations | object | `{}` | | +| ingester.​zoneAwareness.​zoneC.​extraAffinity | object | `{}` | | +| ingester.​zoneAwareness.​zoneC.​nodeSelector | object | `{}` | | +| ingester.​zoneAwareness.​zoneC.​podAnnotations | object | `{}` | | +| ingester.​zoneAwareness.​zoneC.​podLabels | object | `{}` | | +| ingester.​zoneAwareness.​zoneC.​replicas | int | `1` | | +| ingester.​zoneAwareness.​zoneC.​tolerations | list | `[]` | | | ingress.​annotations | object | `{}` | | | ingress.​enabled | bool | `false` | | | ingress.​hosts[0].​host | string | `"chart-example.local"` | |