Skip to content

Commit

Permalink
fix: change headless service to gRPC and expose 9094 TCP (#494)
Browse files Browse the repository at this point in the history
* change alertmanager-svc-headless from http to grpc port

Signed-off-by: AlexandreRoux <[email protected]>

* edit CHANGELOG.md

Signed-off-by: AlexandreRoux <[email protected]>

* expose 9094 TCP UDP for gossip cluster

Signed-off-by: AlexandreRoux <[email protected]>

* support configuration of gossip cluster port

Signed-off-by: AlexandreRoux <[email protected]>

* WIP: configure alertmanager HA cluster mode for sts

Signed-off-by: Niclas Schad <[email protected]>

* configure alertmanager cluster peers as comma seperated list

Signed-off-by: AlexandreRoux <[email protected]>

* clarify values.yaml about cluster enable by default

Signed-off-by: AlexandreRoux <[email protected]>

* replicaset should not set -alertmanager-cluster-peers when cluster is disable

Signed-off-by: AlexandreRoux <[email protected]>

* fix wrong name for grpc targetPort

Signed-off-by: AlexandreRoux <[email protected]>

* re-introduce alertmanager-dep.yaml

Signed-off-by: AlexandreRoux <[email protected]>

* docs: update READEME.md

Signed-off-by: Loc Mai <[email protected]>

* update CHANGELOG.md

Signed-off-by: Loc Mai <[email protected]>

* update CHANGELOG.md

Signed-off-by: Loc Mai <[email protected]>

* update CHANGELOG.md

Signed-off-by: Loc Mai <[email protected]>

* update CHANGELOG.md

Signed-off-by: Loc Mai <[email protected]>

* update CHANGELOG.md

Signed-off-by: Loc Mai <[email protected]>

* update CHANGELOG.md

Signed-off-by: Loc Mai <[email protected]>

* add Alertmanager scope

Signed-off-by: Loc Mai <[email protected]>

* add http-metrics back

Signed-off-by: Loc Mai <[email protected]>

* update CHANGELOG.md

Signed-off-by: Loc Mai <[email protected]>

---------

Signed-off-by: AlexandreRoux <[email protected]>
Signed-off-by: Niclas Schad <[email protected]>
Signed-off-by: Loc Mai <[email protected]>
Co-authored-by: AlexandreRoux <[email protected]>
Co-authored-by: Niclas Schad <[email protected]>
  • Loading branch information
3 people authored Apr 9, 2024
1 parent a572813 commit 1ad5dfb
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 4 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,10 @@

## master / unreleased

* [ENHANCEMENT] Alertmanager: Add `grpc` port #494
* [ENHANCEMENT] Alertmanager: Expose 9094 TCP and UDP for gossip cluster #494
* If the AlertManager headless service existed prior to applying the change, it will have only one port set, which is a known issue. See [kubernetes/kubernetes#39188](https://github.com/kubernetes/kubernetes/issues/39188). Re-creating the headless service can resolve this issue

## 2.2.0 / 2024-01-16

* [CHANGE] Removed `config.storage.engine` and any reference of it #488
Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -216,6 +216,7 @@ Kubernetes: `^1.19.0-0`
| compactor.&ZeroWidthSpace;terminationGracePeriodSeconds | int | `240` | |
| compactor.&ZeroWidthSpace;tolerations | list | `[]` | |
| compactor.&ZeroWidthSpace;topologySpreadConstraints | list | `[]` | |
| config.&ZeroWidthSpace;alertmanager.&ZeroWidthSpace;cluster | object | `{"listen_address":"0.0.0.0:9094"}` | Disable alertmanager gossip cluster by setting empty listen_address to empty string |
| config.&ZeroWidthSpace;alertmanager.&ZeroWidthSpace;enable_api | bool | `false` | Enable the experimental alertmanager config api. |
| config.&ZeroWidthSpace;alertmanager.&ZeroWidthSpace;external_url | string | `"/api/prom/alertmanager"` | |
| config.&ZeroWidthSpace;api.&ZeroWidthSpace;prometheus_http_prefix | string | `"/prometheus"` | |
Expand Down
2 changes: 1 addition & 1 deletion ci/test-deployment-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ runtimeconfigmap:
annotations:
foo: bar
alertmanager:
replicas: 1
replicas: 3
statefulSet:
enabled: false
extraVolumes:
Expand Down
2 changes: 1 addition & 1 deletion ci/test-sts-values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ runtimeconfigmap:
annotations:
foo: bar
alertmanager:
replicas: 1
replicas: 3
statefulSet:
enabled: true
extraVolumes:
Expand Down
20 changes: 20 additions & 0 deletions templates/alertmanager/alertmanager-statefulset.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -152,6 +154,15 @@ spec:
args:
- "-target=alertmanager"
- "-config.file=/etc/cortex/cortex.yaml"
{{- 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 $fullName $.Release.Namespace $svcClusterPort }}
{{- $peers = append $peers $peer }}
{{- end }}
- "-alertmanager.cluster.peers={{ join "," $peers }}"
{{- end }}
{{- range $key, $value := .Values.alertmanager.extraArgs }}
- "-{{ $key }}={{ $value }}"
{{- end }}
Expand All @@ -175,6 +186,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:
Expand Down
14 changes: 12 additions & 2 deletions templates/alertmanager/alertmanager-svc-headless.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
{{- if .Values.alertmanager.enabled -}}
{{- if .Values.alertmanager.statefulSet.enabled -}}
apiVersion: v1
kind: Service
metadata:
Expand All @@ -21,7 +20,18 @@ spec:
protocol: TCP
name: http-metrics
targetPort: http-metrics
- port: {{ .Values.config.server.grpc_listen_port }}
protocol: TCP
name: grpc
targetPort: grpc
- 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 -}}
{{- end -}}
4 changes: 4 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,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'
Expand Down

0 comments on commit 1ad5dfb

Please sign in to comment.