From dcc7660676eeff7052a6842b2b818f7ad136350b Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Thu, 16 Feb 2023 10:03:51 +0100 Subject: [PATCH 01/10] change alertmanager-svc-headless from http to grpc port Signed-off-by: AlexandreRoux --- templates/alertmanager/alertmanager-svc-headless.yaml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/templates/alertmanager/alertmanager-svc-headless.yaml b/templates/alertmanager/alertmanager-svc-headless.yaml index 420c90b6..3d048420 100644 --- a/templates/alertmanager/alertmanager-svc-headless.yaml +++ b/templates/alertmanager/alertmanager-svc-headless.yaml @@ -17,10 +17,10 @@ spec: clusterIP: None publishNotReadyAddresses: true ports: - - port: {{ .Values.config.server.http_listen_port }} + - port: {{ .Values.config.server.grpc_listen_port }} protocol: TCP - name: http-metrics - targetPort: http-metrics + name: grpc + targetPort: grpc selector: {{- include "cortex.alertmanagerSelectorLabels" . | nindent 4 }} {{- end -}} From d8bdc708c3eb31de4d0b95092ab29a72d96050c1 Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Thu, 16 Feb 2023 12:35:27 +0100 Subject: [PATCH 02/10] edit CHANGELOG.md Signed-off-by: AlexandreRoux --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ffe9997b..294c0edf 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,7 @@ * [FEATURE] add autoscaler for the ruler #430 * [ENHANCEMENT] Add annotations and labels to memberlist service #433 +* [CHANGE] change alertmanager-svc-headless from http to grpc port #420 # 2.0.1 / 2023-01-06 From a001e4927814a16000c5bd9bffbed2201c2c4485 Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Wed, 22 Feb 2023 12:49:24 +0100 Subject: [PATCH 03/10] expose 9094 TCP UDP for gossip cluster Signed-off-by: AlexandreRoux --- templates/alertmanager/alertmanager-statefulset.yaml | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/templates/alertmanager/alertmanager-statefulset.yaml b/templates/alertmanager/alertmanager-statefulset.yaml index 60d87d25..ed499048 100644 --- a/templates/alertmanager/alertmanager-statefulset.yaml +++ b/templates/alertmanager/alertmanager-statefulset.yaml @@ -175,6 +175,15 @@ spec: - name: gossip containerPort: {{ .Values.config.memberlist.bind_port }} protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - containerPort: 9094 + name: gossip-clu-tcp + protocol: TCP + - containerPort: 9094 + name: gossip-clu-udp + protocol: UDP startupProbe: {{- toYaml .Values.alertmanager.startupProbe | nindent 12 }} livenessProbe: From e483cd5c4a93a55a15e317d56ea1e115678596af Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Wed, 15 Mar 2023 21:03:56 +0100 Subject: [PATCH 04/10] support configuration of gossip cluster port Signed-off-by: AlexandreRoux --- templates/alertmanager/alertmanager-statefulset.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/alertmanager/alertmanager-statefulset.yaml b/templates/alertmanager/alertmanager-statefulset.yaml index ed499048..7fe7fca4 100644 --- a/templates/alertmanager/alertmanager-statefulset.yaml +++ b/templates/alertmanager/alertmanager-statefulset.yaml @@ -178,10 +178,10 @@ spec: - name: grpc containerPort: {{ .Values.config.server.grpc_listen_port }} protocol: TCP - - containerPort: 9094 + - containerPort: {{ (.Values.config.alertmanager.cluster.listen_address | default "0.0.0.0:9094" | split ":")._1 }} name: gossip-clu-tcp protocol: TCP - - containerPort: 9094 + - containerPort: {{ (.Values.config.alertmanager.cluster.listen_address | default "0.0.0.0:9094" | split ":")._1 }} name: gossip-clu-udp protocol: UDP startupProbe: From 05b3403e679933c0ac1f9a00e95908bb1b392439 Mon Sep 17 00:00:00 2001 From: Niclas Schad Date: Fri, 12 May 2023 09:37:54 +0200 Subject: [PATCH 05/10] WIP: configure alertmanager HA cluster mode for sts Signed-off-by: Niclas Schad --- ci/test-deployment-values.yaml | 2 +- ci/test-sts-values.yaml | 2 +- templates/alertmanager/alertmanager-dep.yaml | 169 ------------------ .../alertmanager-statefulset.yaml | 17 ++ .../alertmanager-svc-headless.yaml | 8 + 5 files changed, 27 insertions(+), 171 deletions(-) delete mode 100644 templates/alertmanager/alertmanager-dep.yaml diff --git a/ci/test-deployment-values.yaml b/ci/test-deployment-values.yaml index 325e5462..e0a677f0 100644 --- a/ci/test-deployment-values.yaml +++ b/ci/test-deployment-values.yaml @@ -128,7 +128,7 @@ runtimeconfigmap: annotations: foo: bar alertmanager: - replicas: 1 + replicas: 3 statefulSet: enabled: false extraVolumes: diff --git a/ci/test-sts-values.yaml b/ci/test-sts-values.yaml index e1a33cc2..14229ceb 100644 --- a/ci/test-sts-values.yaml +++ b/ci/test-sts-values.yaml @@ -119,7 +119,7 @@ runtimeconfigmap: annotations: foo: bar alertmanager: - replicas: 1 + replicas: 3 statefulSet: enabled: true extraVolumes: diff --git a/templates/alertmanager/alertmanager-dep.yaml b/templates/alertmanager/alertmanager-dep.yaml deleted file mode 100644 index 0dcb2128..00000000 --- a/templates/alertmanager/alertmanager-dep.yaml +++ /dev/null @@ -1,169 +0,0 @@ -{{- if .Values.alertmanager.enabled -}} -{{- if not .Values.alertmanager.statefulSet.enabled -}} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: {{ include "cortex.alertmanagerFullname" . }} - namespace: {{ .Release.Namespace }} - labels: - {{- include "cortex.alertmanagerLabels" . | nindent 4 }} - app.kubernetes.io/part-of: memberlist - annotations: - {{- toYaml .Values.alertmanager.annotations | nindent 4 }} -spec: - replicas: {{ .Values.alertmanager.replicas }} - selector: - matchLabels: - {{- include "cortex.alertmanagerSelectorLabels" . | nindent 6 }} - strategy: - {{- toYaml .Values.alertmanager.strategy | nindent 4 }} - template: - metadata: - labels: - {{- include "cortex.alertmanagerLabels" . | nindent 8 }} - app.kubernetes.io/part-of: memberlist - {{- with .Values.alertmanager.podLabels }} - {{- toYaml . | nindent 8 }} - {{- end }} - annotations: - checksum/config: {{ include "cortex.configChecksum" . }} - {{- with .Values.alertmanager.podAnnotations }} - {{- toYaml . | nindent 8 }} - {{- end }} - spec: - serviceAccountName: {{ .Values.alertmanager.serviceAccount.name | default (include "cortex.serviceAccountName" . ) }} - {{- if .Values.alertmanager.priorityClassName }} - priorityClassName: {{ .Values.alertmanager.priorityClassName }} - {{- end }} - {{- if .Values.alertmanager.securityContext.enabled }} - securityContext: {{- omit .Values.alertmanager.securityContext "enabled" | toYaml | nindent 8 }} - {{- end }} - initContainers: - {{- toYaml .Values.alertmanager.initContainers | nindent 8 }} - {{- if .Values.image.pullSecrets }} - imagePullSecrets: - {{- range .Values.image.pullSecrets }} - - name: {{ . }} - {{- end }} - {{- end }} - containers: - {{- if .Values.alertmanager.sidecar.enabled }} - - name: {{ template "cortex.name" . }}-sc-alertmanager - {{- if .Values.alertmanager.sidecar.image.sha }} - image: "{{ .Values.alertmanager.sidecar.image.repository }}:{{ .Values.alertmanager.sidecar.image.tag }}@sha256:{{ .Values.alertmanager.sidecar.image.sha }}" - {{- else }} - image: "{{ .Values.alertmanager.sidecar.image.repository }}:{{ .Values.alertmanager.sidecar.image.tag }}" - {{- end }} - imagePullPolicy: {{ .Values.alertmanager.sidecar.imagePullPolicy }} - env: - {{- if .Values.alertmanager.sidecar.watchMethod }} - - name: METHOD - value: {{ .Values.alertmanager.sidecar.watchMethod }} - {{ end }} - - name: LABEL - value: "{{ .Values.alertmanager.sidecar.label }}" - {{- if .Values.alertmanager.sidecar.labelValue }} - - name: LABEL_VALUE - value: {{ quote .Values.alertmanager.sidecar.labelValue }} - {{- end }} - - name: FOLDER - value: "{{ .Values.alertmanager.sidecar.folder }}{{- with .Values.alertmanager.sidecar.defaultFolderName }}/{{ . }}{{- end }}" - {{- if .Values.alertmanager.sidecar.resource}} - - name: RESOURCE - value: {{ quote .Values.alertmanager.sidecar.resource }} - {{- end }} - {{- if .Values.alertmanager.sidecar.enableUniqueFilenames }} - - name: UNIQUE_FILENAMES - value: "{{ .Values.alertmanager.sidecar.enableUniqueFilenames }}" - {{- end }} - {{- if .Values.alertmanager.sidecar.searchNamespace }} - - name: NAMESPACE - value: "{{ .Values.alertmanager.sidecar.searchNamespace }}" - {{- end }} - {{- if .Values.alertmanager.sidecar.skipTlsVerify }} - - name: SKIP_TLS_VERIFY - value: "{{ .Values.alertmanager.sidecar.skipTlsVerify }}" - {{- end }} - {{- if .Values.alertmanager.sidecar.folderAnnotation }} - - name: FOLDER_ANNOTATION - value: "{{ .Values.alertmanager.sidecar.folderAnnotation }}" - {{- end }} - resources: - {{- toYaml .Values.alertmanager.sidecar.resources | nindent 12 }} - {{- if .Values.alertmanager.sidecar.containerSecurityContext.enabled }} - securityContext: {{- omit .Values.alertmanager.sidecar.containerSecurityContext "enabled" | toYaml | nindent 12 }} - {{- end }} - volumeMounts: - - name: storage - mountPath: "/data" - {{- end }} - - name: alertmanager - image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" - imagePullPolicy: {{ .Values.image.pullPolicy }} - args: - - "-target=alertmanager" - - "-config.file=/etc/cortex/cortex.yaml" - {{- range $key, $value := .Values.alertmanager.extraArgs }} - - "-{{ $key }}={{ $value }}" - {{- end }} - volumeMounts: - {{- if .Values.alertmanager.extraVolumeMounts }} - {{- toYaml .Values.alertmanager.extraVolumeMounts | nindent 12}} - {{- end }} - - name: config - mountPath: /etc/cortex - - name: runtime-config - mountPath: /etc/cortex-runtime-config - - name: storage - mountPath: "/data" - {{- with .Values.alertmanager.persistentVolume.subPath }} - subPath: {{ . }} - {{- end }} - ports: - - name: http-metrics - containerPort: {{ .Values.config.server.http_listen_port }} - protocol: TCP - - name: gossip - containerPort: {{ .Values.config.memberlist.bind_port }} - protocol: TCP - startupProbe: - {{- toYaml .Values.alertmanager.startupProbe | nindent 12 }} - livenessProbe: - {{- toYaml .Values.alertmanager.livenessProbe | nindent 12 }} - readinessProbe: - {{- toYaml .Values.alertmanager.readinessProbe | nindent 12 }} - resources: - {{- toYaml .Values.alertmanager.resources | nindent 12 }} - {{- if .Values.alertmanager.containerSecurityContext.enabled }} - securityContext: {{- omit .Values.alertmanager.containerSecurityContext "enabled" | toYaml | nindent 12 }} - {{- end }} - {{- if .Values.alertmanager.env }} - env: - {{- toYaml .Values.alertmanager.env | nindent 12 }} - {{- end }} - {{- if .Values.alertmanager.extraContainers }} - {{- toYaml .Values.alertmanager.extraContainers | nindent 8}} - {{- end }} - nodeSelector: - {{- toYaml .Values.alertmanager.nodeSelector | nindent 8 }} - {{- if .Values.alertmanager.topologySpreadConstraints }} - topologySpreadConstraints: - {{- toYaml .Values.alertmanager.topologySpreadConstraints | nindent 8}} - {{- end }} - affinity: - {{- toYaml .Values.alertmanager.affinity | nindent 8 }} - tolerations: - {{- toYaml .Values.alertmanager.tolerations | nindent 8 }} - terminationGracePeriodSeconds: {{ .Values.alertmanager.terminationGracePeriodSeconds }} - volumes: - {{- include "cortex.configVolume" . | nindent 8 }} - - name: runtime-config - configMap: - name: {{ template "cortex.fullname" . }}-runtime-config - - name: storage - emptyDir: {} - {{- if .Values.alertmanager.extraVolumes }} - {{- toYaml .Values.alertmanager.extraVolumes | nindent 8 }} - {{- end }} -{{- end -}} -{{- end -}} diff --git a/templates/alertmanager/alertmanager-statefulset.yaml b/templates/alertmanager/alertmanager-statefulset.yaml index 60d87d25..41b592b0 100644 --- a/templates/alertmanager/alertmanager-statefulset.yaml +++ b/templates/alertmanager/alertmanager-statefulset.yaml @@ -1,3 +1,5 @@ +{{- $svcClusterAddress := ((.Values.config.alertmanager.cluster).listen_address) | default "0.0.0.0:9094" }} +{{- $svcClusterPort := (split ":" $svcClusterAddress)._1 }} {{- if .Values.alertmanager.enabled -}} {{- if .Values.alertmanager.statefulSet.enabled -}} apiVersion: apps/v1 @@ -152,6 +154,12 @@ spec: args: - "-target=alertmanager" - "-config.file=/etc/cortex/cortex.yaml" + {{- if gt (int .Values.alertmanager.replicas) 1}} + {{- $fullName := include "cortex.alertmanagerFullname" . }} + {{- range $i := until (int .Values.alertmanager.replicas) }} + - "-alertmanager.cluster.peers={{ $fullName }}-{{ $i }}.{{ $fullName }}-headless.{{ $.Release.Namespace }}.svc.cluster.local:{{ $svcClusterPort }}" + {{- end }} + {{- end }} {{- range $key, $value := .Values.alertmanager.extraArgs }} - "-{{ $key }}={{ $value }}" {{- end }} @@ -175,6 +183,15 @@ spec: - name: gossip containerPort: {{ .Values.config.memberlist.bind_port }} protocol: TCP + - name: grpc + containerPort: {{ .Values.config.server.grpc_listen_port }} + protocol: TCP + - containerPort: {{ $svcClusterPort }} + name: alert-clu-tcp + protocol: TCP + - containerPort: {{ $svcClusterPort }} + name: alert-clu-udp + protocol: UDP startupProbe: {{- toYaml .Values.alertmanager.startupProbe | nindent 12 }} livenessProbe: diff --git a/templates/alertmanager/alertmanager-svc-headless.yaml b/templates/alertmanager/alertmanager-svc-headless.yaml index 420c90b6..e772933b 100644 --- a/templates/alertmanager/alertmanager-svc-headless.yaml +++ b/templates/alertmanager/alertmanager-svc-headless.yaml @@ -21,6 +21,14 @@ spec: protocol: TCP name: http-metrics targetPort: http-metrics + - port: 9094 + protocol: UDP + name: alert-clu-udp + targetPort: alert-clu-udp + - port: 9094 + protocol: TCP + name: alert-clu-tcp + targetPort: alert-clu-tcp selector: {{- include "cortex.alertmanagerSelectorLabels" . | nindent 4 }} {{- end -}} From 1d830da0f1d2e96d6074f9b8d07ca051b886dc08 Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Mon, 3 Jul 2023 16:07:26 +0200 Subject: [PATCH 06/10] configure alertmanager cluster peers as comma seperated list Signed-off-by: AlexandreRoux --- templates/alertmanager/alertmanager-statefulset.yaml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/templates/alertmanager/alertmanager-statefulset.yaml b/templates/alertmanager/alertmanager-statefulset.yaml index 41b592b0..562b91d2 100644 --- a/templates/alertmanager/alertmanager-statefulset.yaml +++ b/templates/alertmanager/alertmanager-statefulset.yaml @@ -156,9 +156,12 @@ spec: - "-config.file=/etc/cortex/cortex.yaml" {{- if gt (int .Values.alertmanager.replicas) 1}} {{- $fullName := include "cortex.alertmanagerFullname" . }} + {{- $peers := list }} {{- range $i := until (int .Values.alertmanager.replicas) }} - - "-alertmanager.cluster.peers={{ $fullName }}-{{ $i }}.{{ $fullName }}-headless.{{ $.Release.Namespace }}.svc.cluster.local:{{ $svcClusterPort }}" + {{- $peer := printf "%s-%d.%s-headless.%s.svc.cluster.local:%s" $fullName $i $.Release.Namespace $.Release.Namespace $svcClusterPort }} + {{- $peers = append $peers $peer }} {{- end }} + - "-alertmanager.cluster.peers={{ join "," $peers }}" {{- end }} {{- range $key, $value := .Values.alertmanager.extraArgs }} - "-{{ $key }}={{ $value }}" From e909803ad4a99142f200e25c844ef3abd803ffe4 Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Tue, 4 Jul 2023 16:12:52 +0200 Subject: [PATCH 07/10] clarify values.yaml about cluster enable by default Signed-off-by: AlexandreRoux --- values.yaml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/values.yaml b/values.yaml index 314bb8bf..0516f9ed 100644 --- a/values.yaml +++ b/values.yaml @@ -129,6 +129,10 @@ config: runtime_config: file: /etc/cortex-runtime-config/runtime_config.yaml alertmanager: + # -- Enable alertmanager gossip cluster + # -- Disable alertmanager gossip cluster by setting empty listen_address to empty string + cluster: + listen_address: '0.0.0.0:9094' # -- Enable the experimental alertmanager config api. enable_api: false external_url: '/api/prom/alertmanager' From b9efaee07f9326130dc386b9ab30ab929b9dc728 Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Tue, 4 Jul 2023 16:14:34 +0200 Subject: [PATCH 08/10] replicaset should not set -alertmanager-cluster-peers when cluster is disable Signed-off-by: AlexandreRoux --- templates/alertmanager/alertmanager-statefulset.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/alertmanager/alertmanager-statefulset.yaml b/templates/alertmanager/alertmanager-statefulset.yaml index 562b91d2..7d6c0d4e 100644 --- a/templates/alertmanager/alertmanager-statefulset.yaml +++ b/templates/alertmanager/alertmanager-statefulset.yaml @@ -154,11 +154,11 @@ spec: args: - "-target=alertmanager" - "-config.file=/etc/cortex/cortex.yaml" - {{- if gt (int .Values.alertmanager.replicas) 1}} + {{- if and (gt (int .Values.alertmanager.replicas) 1) (ne .Values.config.alertmanager.cluster.listen_address "") }} {{- $fullName := include "cortex.alertmanagerFullname" . }} {{- $peers := list }} {{- range $i := until (int .Values.alertmanager.replicas) }} - {{- $peer := printf "%s-%d.%s-headless.%s.svc.cluster.local:%s" $fullName $i $.Release.Namespace $.Release.Namespace $svcClusterPort }} + {{- $peer := printf "%s-%d.%s-headless.%s.svc.cluster.local:%s" $fullName $i $fullName $.Release.Namespace $svcClusterPort }} {{- $peers = append $peers $peer }} {{- end }} - "-alertmanager.cluster.peers={{ join "," $peers }}" From 87e6eb4fb5d9aa4fda57a0f30f93e5f2a80fc076 Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Wed, 26 Jul 2023 10:44:38 +0200 Subject: [PATCH 09/10] fix wrong name for grpc targetPort Signed-off-by: AlexandreRoux --- templates/alertmanager/alertmanager-svc-headless.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/templates/alertmanager/alertmanager-svc-headless.yaml b/templates/alertmanager/alertmanager-svc-headless.yaml index 1ee59bc1..ea56c8e0 100644 --- a/templates/alertmanager/alertmanager-svc-headless.yaml +++ b/templates/alertmanager/alertmanager-svc-headless.yaml @@ -19,8 +19,8 @@ spec: ports: - port: {{ .Values.config.server.grpc_listen_port }} protocol: TCP - name: http-metrics - targetPort: http-metrics + name: grpc + targetPort: grpc - port: 9094 protocol: UDP name: alert-clu-udp From 62c12223193678ffa63b70e5604a1851c2a7a033 Mon Sep 17 00:00:00 2001 From: AlexandreRoux Date: Wed, 26 Jul 2023 12:09:08 +0200 Subject: [PATCH 10/10] re-introduce alertmanager-dep.yaml Signed-off-by: AlexandreRoux --- templates/alertmanager/alertmanager-dep.yaml | 169 ++++++++++++++++++ .../alertmanager-svc-headless.yaml | 2 - 2 files changed, 169 insertions(+), 2 deletions(-) create mode 100644 templates/alertmanager/alertmanager-dep.yaml diff --git a/templates/alertmanager/alertmanager-dep.yaml b/templates/alertmanager/alertmanager-dep.yaml new file mode 100644 index 00000000..0dcb2128 --- /dev/null +++ b/templates/alertmanager/alertmanager-dep.yaml @@ -0,0 +1,169 @@ +{{- if .Values.alertmanager.enabled -}} +{{- if not .Values.alertmanager.statefulSet.enabled -}} +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "cortex.alertmanagerFullname" . }} + namespace: {{ .Release.Namespace }} + labels: + {{- include "cortex.alertmanagerLabels" . | nindent 4 }} + app.kubernetes.io/part-of: memberlist + annotations: + {{- toYaml .Values.alertmanager.annotations | nindent 4 }} +spec: + replicas: {{ .Values.alertmanager.replicas }} + selector: + matchLabels: + {{- include "cortex.alertmanagerSelectorLabels" . | nindent 6 }} + strategy: + {{- toYaml .Values.alertmanager.strategy | nindent 4 }} + template: + metadata: + labels: + {{- include "cortex.alertmanagerLabels" . | nindent 8 }} + app.kubernetes.io/part-of: memberlist + {{- with .Values.alertmanager.podLabels }} + {{- toYaml . | nindent 8 }} + {{- end }} + annotations: + checksum/config: {{ include "cortex.configChecksum" . }} + {{- with .Values.alertmanager.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + spec: + serviceAccountName: {{ .Values.alertmanager.serviceAccount.name | default (include "cortex.serviceAccountName" . ) }} + {{- if .Values.alertmanager.priorityClassName }} + priorityClassName: {{ .Values.alertmanager.priorityClassName }} + {{- end }} + {{- if .Values.alertmanager.securityContext.enabled }} + securityContext: {{- omit .Values.alertmanager.securityContext "enabled" | toYaml | nindent 8 }} + {{- end }} + initContainers: + {{- toYaml .Values.alertmanager.initContainers | nindent 8 }} + {{- if .Values.image.pullSecrets }} + imagePullSecrets: + {{- range .Values.image.pullSecrets }} + - name: {{ . }} + {{- end }} + {{- end }} + containers: + {{- if .Values.alertmanager.sidecar.enabled }} + - name: {{ template "cortex.name" . }}-sc-alertmanager + {{- if .Values.alertmanager.sidecar.image.sha }} + image: "{{ .Values.alertmanager.sidecar.image.repository }}:{{ .Values.alertmanager.sidecar.image.tag }}@sha256:{{ .Values.alertmanager.sidecar.image.sha }}" + {{- else }} + image: "{{ .Values.alertmanager.sidecar.image.repository }}:{{ .Values.alertmanager.sidecar.image.tag }}" + {{- end }} + imagePullPolicy: {{ .Values.alertmanager.sidecar.imagePullPolicy }} + env: + {{- if .Values.alertmanager.sidecar.watchMethod }} + - name: METHOD + value: {{ .Values.alertmanager.sidecar.watchMethod }} + {{ end }} + - name: LABEL + value: "{{ .Values.alertmanager.sidecar.label }}" + {{- if .Values.alertmanager.sidecar.labelValue }} + - name: LABEL_VALUE + value: {{ quote .Values.alertmanager.sidecar.labelValue }} + {{- end }} + - name: FOLDER + value: "{{ .Values.alertmanager.sidecar.folder }}{{- with .Values.alertmanager.sidecar.defaultFolderName }}/{{ . }}{{- end }}" + {{- if .Values.alertmanager.sidecar.resource}} + - name: RESOURCE + value: {{ quote .Values.alertmanager.sidecar.resource }} + {{- end }} + {{- if .Values.alertmanager.sidecar.enableUniqueFilenames }} + - name: UNIQUE_FILENAMES + value: "{{ .Values.alertmanager.sidecar.enableUniqueFilenames }}" + {{- end }} + {{- if .Values.alertmanager.sidecar.searchNamespace }} + - name: NAMESPACE + value: "{{ .Values.alertmanager.sidecar.searchNamespace }}" + {{- end }} + {{- if .Values.alertmanager.sidecar.skipTlsVerify }} + - name: SKIP_TLS_VERIFY + value: "{{ .Values.alertmanager.sidecar.skipTlsVerify }}" + {{- end }} + {{- if .Values.alertmanager.sidecar.folderAnnotation }} + - name: FOLDER_ANNOTATION + value: "{{ .Values.alertmanager.sidecar.folderAnnotation }}" + {{- end }} + resources: + {{- toYaml .Values.alertmanager.sidecar.resources | nindent 12 }} + {{- if .Values.alertmanager.sidecar.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.alertmanager.sidecar.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + volumeMounts: + - name: storage + mountPath: "/data" + {{- end }} + - name: alertmanager + image: "{{ .Values.image.repository }}:{{ default .Chart.AppVersion .Values.image.tag }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + args: + - "-target=alertmanager" + - "-config.file=/etc/cortex/cortex.yaml" + {{- range $key, $value := .Values.alertmanager.extraArgs }} + - "-{{ $key }}={{ $value }}" + {{- end }} + volumeMounts: + {{- if .Values.alertmanager.extraVolumeMounts }} + {{- toYaml .Values.alertmanager.extraVolumeMounts | nindent 12}} + {{- end }} + - name: config + mountPath: /etc/cortex + - name: runtime-config + mountPath: /etc/cortex-runtime-config + - name: storage + mountPath: "/data" + {{- with .Values.alertmanager.persistentVolume.subPath }} + subPath: {{ . }} + {{- end }} + ports: + - name: http-metrics + containerPort: {{ .Values.config.server.http_listen_port }} + protocol: TCP + - name: gossip + containerPort: {{ .Values.config.memberlist.bind_port }} + protocol: TCP + startupProbe: + {{- toYaml .Values.alertmanager.startupProbe | nindent 12 }} + livenessProbe: + {{- toYaml .Values.alertmanager.livenessProbe | nindent 12 }} + readinessProbe: + {{- toYaml .Values.alertmanager.readinessProbe | nindent 12 }} + resources: + {{- toYaml .Values.alertmanager.resources | nindent 12 }} + {{- if .Values.alertmanager.containerSecurityContext.enabled }} + securityContext: {{- omit .Values.alertmanager.containerSecurityContext "enabled" | toYaml | nindent 12 }} + {{- end }} + {{- if .Values.alertmanager.env }} + env: + {{- toYaml .Values.alertmanager.env | nindent 12 }} + {{- end }} + {{- if .Values.alertmanager.extraContainers }} + {{- toYaml .Values.alertmanager.extraContainers | nindent 8}} + {{- end }} + nodeSelector: + {{- toYaml .Values.alertmanager.nodeSelector | nindent 8 }} + {{- if .Values.alertmanager.topologySpreadConstraints }} + topologySpreadConstraints: + {{- toYaml .Values.alertmanager.topologySpreadConstraints | nindent 8}} + {{- end }} + affinity: + {{- toYaml .Values.alertmanager.affinity | nindent 8 }} + tolerations: + {{- toYaml .Values.alertmanager.tolerations | nindent 8 }} + terminationGracePeriodSeconds: {{ .Values.alertmanager.terminationGracePeriodSeconds }} + volumes: + {{- include "cortex.configVolume" . | nindent 8 }} + - name: runtime-config + configMap: + name: {{ template "cortex.fullname" . }}-runtime-config + - name: storage + emptyDir: {} + {{- if .Values.alertmanager.extraVolumes }} + {{- toYaml .Values.alertmanager.extraVolumes | nindent 8 }} + {{- end }} +{{- end -}} +{{- end -}} diff --git a/templates/alertmanager/alertmanager-svc-headless.yaml b/templates/alertmanager/alertmanager-svc-headless.yaml index ea56c8e0..8d8e5727 100644 --- a/templates/alertmanager/alertmanager-svc-headless.yaml +++ b/templates/alertmanager/alertmanager-svc-headless.yaml @@ -1,5 +1,4 @@ {{- if .Values.alertmanager.enabled -}} -{{- if .Values.alertmanager.statefulSet.enabled -}} apiVersion: v1 kind: Service metadata: @@ -32,4 +31,3 @@ spec: selector: {{- include "cortex.alertmanagerSelectorLabels" . | nindent 4 }} {{- end -}} -{{- end -}}