eve*_*der 8 kubernetes kubernetes-helm prometheus-alertmanager kube-prometheus-stack
我正在从 Helm Chart 部署一个监控堆栈kube-prometheus-stack,并尝试配置 Alertmanager,以便它具有我的自定义配置,用于在 Slack 通道中发出警报。
Pod 中的配置是从 加载的/etc/alertmanager/config/alertmanager.yaml。从 Pod 描述来看,该文件是从自动生成的 Secret 中加载的:
...
volumeMounts:
- mountPath: /etc/alertmanager/config
name: config-volume
...
volumes:
- name: config-volume
secret:
defaultMode: 420
secretName: alertmanager-prometheus-community-kube-alertmanager-generated
Run Code Online (Sandbox Code Playgroud)
如果我检查秘密,它包含在默认值中找到的默认配置alertmanager.config,我打算覆盖它。
如果我将以下配置传递给alertmanager以全新安装图表,它不会创建alertmanager pod:
alertmanager:
config:
global:
resolve_timeout: 5m
route:
group_by: ['job', 'alertname', 'priority']
group_wait: 10s
group_interval: 1m
routes:
- match:
alertname: Watchdog
receiver: 'null'
- receiver: 'slack-notifications'
continue: true
receivers:
- name: 'slack-notifications'
slack-configs:
- slack_api_url: <url here>
title: '{{ .Status }} ({{ .Alerts.Firing | len }}): {{ .GroupLabels.SortedPairs.Values | join " " }}'
text: '<!channel> {{ .CommonAnnotations.summary }}'
channel: '#mychannel'
Run Code Online (Sandbox Code Playgroud)
首先,如果我没有在 中传递任何配置values.yaml,则alertmanager pod创建成功。
如何正确覆盖alertmanager的配置,以便它将带有我的自定义配置的正确文件安装到/etc/alertmanger/config/alertmanager.yaml?
警报管理器需要某些非默认参数来覆盖默认值,因为它似乎默默地失败了。错误的配置会导致 pod 不应用配置(https://github.com/prometheus-community/helm-charts/issues/1998)。对我有用的是仔细配置警报管理器并添加看门狗子路由和空接收器
route:
group_by: [ '...' ]
group_wait: 30s
group_interval: 10s
repeat_interval: 10s
receiver: 'user1'
routes:
- match:
alertname: Watchdog
receiver: 'null'
receivers:
- name: 'null'
- ...
Run Code Online (Sandbox Code Playgroud)
小智 1
也许以下步骤可以解决您的问题
1)从自定义alertmanager.yaml文件创建Config映射
kubectl create configmap <name_of_the_configmap> --from-file=<path_and_name_of_thefile>
Run Code Online (Sandbox Code Playgroud)
2)将Configmap作为卷挂载到容器中。
...
volumeMounts:
- mountPath: /etc/alertmanager/config
name: config-volume
volumes:
- name: config-volume
configMap:
# Provide the name of the ConfigMap containing the files you want
# to add to the container
name: <ConfigMap_Name_Created>
Run Code Online (Sandbox Code Playgroud)
3)挂载configmap将覆盖容器内的文件。
| 归档时间: |
|
| 查看次数: |
10263 次 |
| 最近记录: |