forked from prometheus-community/helm-charts
-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #46 from junotx/alertmanager
[alertmanager] customize to support to use global.imageRegistry and global.nodeSelector
- Loading branch information
Showing
21 changed files
with
1,751 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
# Patterns to ignore when building packages. | ||
# This supports shell glob matching, relative path matching, and | ||
# negation (prefixed with !). Only one pattern per line. | ||
.DS_Store | ||
# Common VCS dirs | ||
.git/ | ||
.gitignore | ||
.bzr/ | ||
.bzrignore | ||
.hg/ | ||
.hgignore | ||
.svn/ | ||
# Common backup files | ||
*.swp | ||
*.bak | ||
*.tmp | ||
*.orig | ||
*~ | ||
# Various IDEs | ||
.project | ||
.idea/ | ||
*.tmproj | ||
.vscode/ | ||
|
||
unittests/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
apiVersion: v2 | ||
name: alertmanager | ||
description: The Alertmanager handles alerts sent by client applications such as the Prometheus server. | ||
home: https://prometheus.io/ | ||
icon: https://raw.githubusercontent.com/prometheus/prometheus.github.io/master/assets/prometheus_logo-cb55bb5c346.png | ||
sources: | ||
- https://github.com/prometheus/alertmanager | ||
type: application | ||
version: 1.8.1 | ||
appVersion: v0.26.0 | ||
kubeVersion: ">=1.19.0-0" | ||
keywords: | ||
- monitoring | ||
maintainers: | ||
- name: monotek | ||
email: [email protected] | ||
- name: naseemkullah | ||
email: [email protected] | ||
annotations: | ||
"artifacthub.io/license": Apache-2.0 | ||
"artifacthub.io/links": | | ||
- name: Chart Source | ||
url: https://github.com/prometheus-community/helm-charts |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
# Alertmanager | ||
|
||
As per [prometheus.io documentation](https://prometheus.io/docs/alerting/latest/alertmanager/): | ||
> The Alertmanager handles alerts sent by client applications such as the | ||
> Prometheus server. It takes care of deduplicating, grouping, and routing them | ||
> to the correct receiver integration such as email, PagerDuty, or OpsGenie. It | ||
> also takes care of silencing and inhibition of alerts. | ||
## Prerequisites | ||
|
||
Kubernetes 1.14+ | ||
|
||
## Get Repository Info | ||
|
||
```console | ||
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts | ||
helm repo update | ||
``` | ||
|
||
_See [`helm repo`](https://helm.sh/docs/helm/helm_repo/) for command documentation._ | ||
|
||
## Install Chart | ||
|
||
```console | ||
helm install [RELEASE_NAME] prometheus-community/alertmanager | ||
``` | ||
|
||
_See [configuration](#configuration) below._ | ||
|
||
_See [helm install](https://helm.sh/docs/helm/helm_install/) for command documentation._ | ||
|
||
## Uninstall Chart | ||
|
||
```console | ||
helm uninstall [RELEASE_NAME] | ||
``` | ||
|
||
This removes all the Kubernetes components associated with the chart and deletes the release. | ||
|
||
_See [helm uninstall](https://helm.sh/docs/helm/helm_uninstall/) for command documentation._ | ||
|
||
## Upgrading Chart | ||
|
||
```console | ||
helm upgrade [RELEASE_NAME] [CHART] --install | ||
``` | ||
|
||
_See [helm upgrade](https://helm.sh/docs/helm/helm_upgrade/) for command documentation._ | ||
|
||
### To 1.0 | ||
|
||
The [configmap-reload](https://github.com/jimmidyson/configmap-reload) container was replaced by the [prometheus-config-reloader](https://github.com/prometheus-operator/prometheus-operator/tree/main/cmd/prometheus-config-reloader). | ||
Extra command-line arguments specified via configmapReload.prometheus.extraArgs are not compatible and will break with the new prometheus-config-reloader, refer to the [sources](https://github.com/prometheus-operator/prometheus-operator/blob/main/cmd/prometheus-config-reloader/main.go) in order to make the appropriate adjustment to the extea command-line arguments. | ||
The `networking.k8s.io/v1beta1` is no longer supported. use [`networking.k8s.io/v1`](https://kubernetes.io/docs/reference/using-api/deprecation-guide/#ingressclass-v122). | ||
|
||
## Configuration | ||
|
||
See [Customizing the Chart Before Installing](https://helm.sh/docs/intro/using_helm/#customizing-the-chart-before-installing). To see all configurable options with detailed comments, visit the chart's [values.yaml](./values.yaml), or run these configuration commands: | ||
|
||
```console | ||
helm show values prometheus-community/alertmanager | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
configmapReload: | ||
enabled: true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
1. Get the application URL by running these commands: | ||
{{- if .Values.ingress.enabled }} | ||
{{- range $host := .Values.ingress.hosts }} | ||
{{- range .paths }} | ||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }} | ||
{{- end }} | ||
{{- end }} | ||
{{- else if contains "NodePort" .Values.service.type }} | ||
export NODE_PORT=$(kubectl get --namespace {{ include "alertmanager.namespace" . }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "alertmanager.fullname" . }}) | ||
export NODE_IP=$(kubectl get nodes --namespace {{ include "alertmanager.namespace" . }} -o jsonpath="{.items[0].status.addresses[0].address}") | ||
echo http://$NODE_IP:$NODE_PORT | ||
{{- else if contains "LoadBalancer" .Values.service.type }} | ||
NOTE: It may take a few minutes for the LoadBalancer IP to be available. | ||
You can watch the status of by running 'kubectl get --namespace {{ include "alertmanager.namespace" . }} svc -w {{ include "alertmanager.fullname" . }}' | ||
export SERVICE_IP=$(kubectl get svc --namespace {{ include "alertmanager.namespace" . }} {{ include "alertmanager.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}") | ||
echo http://$SERVICE_IP:{{ .Values.service.port }} | ||
{{- else if contains "ClusterIP" .Values.service.type }} | ||
export POD_NAME=$(kubectl get pods --namespace {{ include "alertmanager.namespace" . }} -l "app.kubernetes.io/name={{ include "alertmanager.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}") | ||
echo "Visit http://127.0.0.1:{{ .Values.service.port }} to use your application" | ||
kubectl --namespace {{ include "alertmanager.namespace" . }} port-forward $POD_NAME {{ .Values.service.port }}:80 | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,92 @@ | ||
{{/* vim: set filetype=mustache: */}} | ||
{{/* | ||
Expand the name of the chart. | ||
*/}} | ||
{{- define "alertmanager.name" -}} | ||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create a default fully qualified app name. | ||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec). | ||
If release name contains chart name it will be used as a full name. | ||
*/}} | ||
{{- define "alertmanager.fullname" -}} | ||
{{- if .Values.fullnameOverride }} | ||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- $name := default .Chart.Name .Values.nameOverride }} | ||
{{- if contains $name .Release.Name }} | ||
{{- .Release.Name | trunc 63 | trimSuffix "-" }} | ||
{{- else }} | ||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create chart name and version as used by the chart label. | ||
*/}} | ||
{{- define "alertmanager.chart" -}} | ||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Common labels | ||
*/}} | ||
{{- define "alertmanager.labels" -}} | ||
helm.sh/chart: {{ include "alertmanager.chart" . }} | ||
{{ include "alertmanager.selectorLabels" . }} | ||
{{- with .Chart.AppVersion }} | ||
app.kubernetes.io/version: {{ . | quote }} | ||
{{- end }} | ||
app.kubernetes.io/managed-by: {{ .Release.Service }} | ||
{{- end }} | ||
|
||
{{/* | ||
Selector labels | ||
*/}} | ||
{{- define "alertmanager.selectorLabels" -}} | ||
app.kubernetes.io/name: {{ include "alertmanager.name" . }} | ||
app.kubernetes.io/instance: {{ .Release.Name }} | ||
{{- end }} | ||
|
||
{{/* | ||
Create the name of the service account to use | ||
*/}} | ||
{{- define "alertmanager.serviceAccountName" -}} | ||
{{- if .Values.serviceAccount.create }} | ||
{{- default (include "alertmanager.fullname" .) .Values.serviceAccount.name }} | ||
{{- else }} | ||
{{- default "default" .Values.serviceAccount.name }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Define Ingress apiVersion | ||
*/}} | ||
{{- define "alertmanager.ingress.apiVersion" -}} | ||
{{- printf "networking.k8s.io/v1" }} | ||
{{- end }} | ||
|
||
{{/* | ||
Define Pdb apiVersion | ||
*/}} | ||
{{- define "alertmanager.pdb.apiVersion" -}} | ||
{{- if $.Capabilities.APIVersions.Has "policy/v1/PodDisruptionBudget" }} | ||
{{- printf "policy/v1" }} | ||
{{- else }} | ||
{{- printf "policy/v1beta1" }} | ||
{{- end }} | ||
{{- end }} | ||
|
||
{{/* | ||
Allow overriding alertmanager namespace | ||
*/}} | ||
{{- define "alertmanager.namespace" -}} | ||
{{- if .Values.namespaceOverride -}} | ||
{{- .Values.namespaceOverride -}} | ||
{{- else -}} | ||
{{- .Release.Namespace -}} | ||
{{- end -}} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
{{- define "alertmanager.common.images.image" -}} | ||
{{- $registryName := "" }} | ||
{{- if and .global .global.imageRegistry }} | ||
{{- $registryName = .global.imageRegistry }} | ||
{{- end }} | ||
{{- $repositoryName := .imageRoot.repository -}} | ||
{{- $separator := ":" -}} | ||
{{- $termination := "" -}} | ||
{{- if and .global .global.tag }} | ||
{{- $termination = .global.tag | toString }} | ||
{{- end }} | ||
{{- if .imageRoot.registry }} | ||
{{- $registryName = .imageRoot.registry -}} | ||
{{- end -}} | ||
{{- if empty $registryName }} | ||
{{- if .imageRoot.defaultRegistry }} | ||
{{- $registryName = .imageRoot.defaultRegistry }} | ||
{{- end -}} | ||
{{- end -}} | ||
{{- if .imageRoot.tag }} | ||
{{- $termination = .imageRoot.tag | toString -}} | ||
{{- end -}} | ||
{{- if .imageRoot.digest }} | ||
{{- $separator = "@" -}} | ||
{{- $termination = .imageRoot.digest | toString -}} | ||
{{- end -}} | ||
{{- if $registryName }} | ||
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}} | ||
{{- else }} | ||
{{- printf "%s%s%s" $repositoryName $separator $termination -}} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{- define "alertmanager.image" -}} | ||
{{- $_dict := (dict "imageRoot" .Values.image "global" .Values.global) }} | ||
{{- if empty $_dict.imageRoot.tag }} | ||
{{- $_ := set $_dict.imageRoot "tag" .Chart.AppVersion }} | ||
{{- end }} | ||
{{- include "alertmanager.common.images.image" $_dict }} | ||
{{- end -}} | ||
|
||
{{- define "alertmanager.configmapReload.image" -}} | ||
{{- $_dict := (dict "imageRoot" .Values.configmapReload.image "global" .Values.global) }} | ||
{{- include "alertmanager.common.images.image" $_dict }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{{- define "alertmanager.common.nodeSelectors.nodeSelector" -}} | ||
{{- if and .global .global.nodeSelector }} | ||
{{- $nodeSelector := .global.nodeSelector -}} | ||
{{- if .nodeSelector }} | ||
{{- $nodeSelector = merge .nodeSelector $nodeSelector -}} | ||
{{- end -}} | ||
{{- toYaml $nodeSelector }} | ||
{{- else }} | ||
{{- toYaml .nodeSelector }} | ||
{{- end }} | ||
{{- end -}} | ||
|
||
{{- define "alertmanager.nodeSelector" -}} | ||
{{- $_dict := (dict "nodeSelector" .Values.nodeSelector "global" .Values.global) }} | ||
{{- include "alertmanager.common.nodeSelectors.nodeSelector" $_dict }} | ||
{{- end -}} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{{- if .Values.config.enabled }} | ||
apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: {{ include "alertmanager.fullname" . }} | ||
labels: | ||
{{- include "alertmanager.labels" . | nindent 4 }} | ||
{{- with .Values.configAnnotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
namespace: {{ include "alertmanager.namespace" . }} | ||
data: | ||
alertmanager.yml: | | ||
{{- $config := omit .Values.config "enabled" }} | ||
{{- toYaml $config | default "{}" | nindent 4 }} | ||
{{- range $key, $value := .Values.templates }} | ||
{{ $key }}: |- | ||
{{- $value | nindent 4 }} | ||
{{- end }} | ||
{{- end }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
{{- if .Values.ingress.enabled }} | ||
{{- $fullName := include "alertmanager.fullname" . }} | ||
{{- $svcPort := .Values.service.port }} | ||
apiVersion: {{ include "alertmanager.ingress.apiVersion" . }} | ||
kind: Ingress | ||
metadata: | ||
name: {{ $fullName }} | ||
labels: | ||
{{- include "alertmanager.labels" . | nindent 4 }} | ||
{{- with .Values.ingress.annotations }} | ||
annotations: | ||
{{- toYaml . | nindent 4 }} | ||
{{- end }} | ||
namespace: {{ include "alertmanager.namespace" . }} | ||
spec: | ||
{{- if .Values.ingress.className }} | ||
ingressClassName: {{ .Values.ingress.className }} | ||
{{- end }} | ||
{{- if .Values.ingress.tls }} | ||
tls: | ||
{{- range .Values.ingress.tls }} | ||
- hosts: | ||
{{- range .hosts }} | ||
- {{ . | quote }} | ||
{{- end }} | ||
secretName: {{ .secretName }} | ||
{{- end }} | ||
{{- end }} | ||
rules: | ||
{{- range .Values.ingress.hosts }} | ||
- host: {{ .host | quote }} | ||
http: | ||
paths: | ||
{{- range .paths }} | ||
- path: {{ .path }} | ||
pathType: {{ .pathType }} | ||
backend: | ||
service: | ||
name: {{ $fullName }} | ||
port: | ||
number: {{ $svcPort }} | ||
{{- end }} | ||
{{- end }} | ||
{{- end }} |
Oops, something went wrong.