From 116493a9b1bebf6c3bd65fd361cf818877074d40 Mon Sep 17 00:00:00 2001 From: Sam McBroom <86423878+sam-mcbr@users.noreply.github.com> Date: Mon, 7 Aug 2023 01:45:15 -0700 Subject: [PATCH] [alertmanager] Add additional configuration options. (#3620) * [alertmanager] Add additional configuration options. Signed-off-by: Sam Mcbroom * Use port names. Signed-off-by: Sam Mcbroom * Extra volume mounts for config reloader. Signed-off-by: Sam Mcbroom * Add extraEnv value for config reloader. Signed-off-by: Sam Mcbroom * Allow restricting config-reloader to only watch specific file. Signed-off-by: Sam Mcbroom * Allow configuring reload endpoint for config reloader. Signed-off-by: Sam Mcbroom * Fix comments in values.yaml. Signed-off-by: Sam Mcbroom * Allow exposing extra ports on the services. Signed-off-by: Sam Mcbroom * Default value for service.extraPorts. Signed-off-by: Sam Mcbroom * Remove unused service port protocol. Signed-off-by: Sam Mcbroom * Fix helm. Signed-off-by: Sam Mcbroom * Enabled UDP port for cluster peer communication. Signed-off-by: Sam Mcbroom * Bump version. Signed-off-by: Sam Mcbroom --------- Signed-off-by: Sam Mcbroom --- charts/alertmanager/Chart.yaml | 2 +- charts/alertmanager/templates/services.yaml | 10 ++++++-- .../alertmanager/templates/statefulset.yaml | 24 +++++++++++++++++++ charts/alertmanager/values.yaml | 16 +++++++++++++ 4 files changed, 49 insertions(+), 3 deletions(-) diff --git a/charts/alertmanager/Chart.yaml b/charts/alertmanager/Chart.yaml index 96497674d135..b28f65d72b12 100644 --- a/charts/alertmanager/Chart.yaml +++ b/charts/alertmanager/Chart.yaml @@ -6,7 +6,7 @@ icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/a sources: - https://github.com/prometheus/alertmanager type: application -version: 1.1.0 +version: 1.2.0 appVersion: v0.25.0 kubeVersion: ">=1.19.0-0" keywords: diff --git a/charts/alertmanager/templates/services.yaml b/charts/alertmanager/templates/services.yaml index 80c606f54867..9637ae7586de 100644 --- a/charts/alertmanager/templates/services.yaml +++ b/charts/alertmanager/templates/services.yaml @@ -31,6 +31,9 @@ spec: {{- if (and (eq .Values.service.type "NodePort") .Values.service.nodePort) }} nodePort: {{ .Values.service.nodePort }} {{- end }} + {{- with .Values.service.extraPorts }} + {{- toYaml . | nindent 4 }} + {{- end }} selector: {{- include "alertmanager.selectorLabels" . | nindent 4 }} --- @@ -53,13 +56,16 @@ spec: name: http {{- if or (gt (int .Values.replicaCount) 1) (.Values.additionalPeers) }} - port: {{ .Values.service.clusterPort }} - targetPort: {{ .Values.service.clusterPort }} + targetPort: clusterpeer-tcp protocol: TCP name: cluster-tcp - port: {{ .Values.service.clusterPort }} - targetPort: {{ .Values.service.clusterPort }} + targetPort: clusterpeer-udp protocol: UDP name: cluster-udp {{- end }} + {{- with .Values.service.extraPorts }} + {{- toYaml . | nindent 4 }} + {{- end }} selector: {{- include "alertmanager.selectorLabels" . | nindent 4 }} diff --git a/charts/alertmanager/templates/statefulset.yaml b/charts/alertmanager/templates/statefulset.yaml index 83979fbf0751..93970f309782 100644 --- a/charts/alertmanager/templates/statefulset.yaml +++ b/charts/alertmanager/templates/statefulset.yaml @@ -97,9 +97,20 @@ spec: - name: {{ .Chart.Name }}-{{ .Values.configmapReload.name }} image: "{{ .Values.configmapReload.image.repository }}:{{ .Values.configmapReload.image.tag }}" imagePullPolicy: "{{ .Values.configmapReload.image.pullPolicy }}" + {{- with .Values.configmapReload.extraEnv }} + env: + {{- toYaml . | nindent 12 }} + {{- end }} args: + {{- if and (hasKey .Values.configmapReload.extraArgs "config-file" | not) (hasKey .Values.configmapReload.extraArgs "watched-dir" | not) }} - --watched-dir=/etc/alertmanager + {{- end }} + {{- if not (hasKey .Values.configmapReload.extraArgs "reload-url") }} - --reload-url=http://127.0.0.1:9093/-/reload + {{- end }} + {{- range $key, $value := .Values.configmapReload.extraArgs }} + - --{{ $key }}={{ $value }} + {{- end }} resources: {{- toYaml .Values.configmapReload.resources | nindent 12 }} {{- with .Values.configmapReload.containerPort }} @@ -109,6 +120,9 @@ spec: volumeMounts: - name: config mountPath: /etc/alertmanager + {{- if .Values.configmapReload.extraVolumeMounts }} + {{- toYaml .Values.configmapReload.extraVolumeMounts | nindent 12 }} + {{- end }} {{- end }} - name: {{ .Chart.Name }} securityContext: @@ -130,7 +144,9 @@ spec: {{- end }} args: - --storage.path=/alertmanager + {{- if not (hasKey .Values.extraArgs "config.file") }} - --config.file=/etc/alertmanager/alertmanager.yml + {{- end }} {{- if or (gt (int .Values.replicaCount) 1) (.Values.additionalPeers) }} - --cluster.advertise-address=[$(POD_IP)]:{{ $svcClusterPort }} - --cluster.listen-address=0.0.0.0:{{ $svcClusterPort }} @@ -153,6 +169,14 @@ spec: - name: http containerPort: 9093 protocol: TCP + {{- if or (gt (int .Values.replicaCount) 1) (.Values.additionalPeers) }} + - name: clusterpeer-tcp + containerPort: {{ $svcClusterPort }} + protocol: TCP + - name: clusterpeer-udp + containerPort: {{ $svcClusterPort }} + protocol: UDP + {{- end }} livenessProbe: {{- toYaml .Values.livenessProbe | nindent 12 }} readinessProbe: diff --git a/charts/alertmanager/values.yaml b/charts/alertmanager/values.yaml index 6c26c10d0431..0ecbaf07fca0 100644 --- a/charts/alertmanager/values.yaml +++ b/charts/alertmanager/values.yaml @@ -107,6 +107,9 @@ service: # if you want to force a specific nodePort. Must be use with service.type=NodePort # nodePort: + # Optionally specify extra list of additional ports exposed on both services + extraPorts: [] + ingress: enabled: false className: "" @@ -245,6 +248,19 @@ configmapReload: ## resources: {} + extraArgs: {} + + ## Optionally specify extra list of additional volumeMounts + extraVolumeMounts: [] + # - name: extras + # mountPath: /usr/share/extras + # readOnly: true + + ## Optionally specify extra environment variables to add to alertmanager container + extraEnv: [] + # - name: FOO + # value: BAR + templates: {} # alertmanager.tmpl: |-