From e0a368ff2fed1ee8db4cd0a262312b257ae36f29 Mon Sep 17 00:00:00 2001 From: "liubo@coding.net" Date: Fri, 24 Dec 2021 15:27:13 +0800 Subject: [PATCH] =?UTF-8?q?helm=20=E6=94=AF=E6=8C=81=E9=80=9A=E8=BF=87?= =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6=E6=96=B0=E5=A2=9E=E6=A8=A1?= =?UTF-8?q?=E7=89=88?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Dockerfile | 2 +- example/helm/prometheusalert/config/init.sql | 3 +++ example/helm/prometheusalert/templates/deployment.yaml | 6 ++++++ example/helm/prometheusalert/values.yaml | 1 + 4 files changed, 11 insertions(+), 1 deletion(-) create mode 100644 example/helm/prometheusalert/config/init.sql diff --git a/Dockerfile b/Dockerfile index 323de733..855e9fb9 100644 --- a/Dockerfile +++ b/Dockerfile @@ -24,7 +24,7 @@ RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories cp /usr/share/zoneinfo/Asia/Shanghai /etc/localtime && \ echo "Asia/Shanghai" > /etc/timezone && \ apk del tzdata && \ - apk update && apk upgrade && apk add --no-cache sqlite-libs curl + apk update && apk upgrade && apk add --no-cache sqlite-libs curl sqlite HEALTHCHECK --start-period=10s --interval=20s --timeout=3s --retries=3 \ CMD curl -fs http://localhost:8080/health || exit 1 diff --git a/example/helm/prometheusalert/config/init.sql b/example/helm/prometheusalert/config/init.sql new file mode 100644 index 00000000..42699aef --- /dev/null +++ b/example/helm/prometheusalert/config/init.sql @@ -0,0 +1,3 @@ +INSERT INTO `prometheus_alert_d_b` VALUES ('50', 'wx', 'Prometheus', 'prometheus-wx-2', '{{ $var := .externalURL}}{{ range $k,$v:=.alerts }}\r\n{{if eq $v.status \"resolved\"}}\r\n[Prometheus恢复信息]($v.generatorURL}})\r\n>**[{{$v.labels.alertname}}]({{$var}})**\r\n>告警级别: {{$v.labels.level}}\r\n开始时间: {{$v.startsAt}}\r\n结束时间: {{$v.endsAt}}\r\n故障主机IP: {{$v.labels.instance}}\r\n**{{$v.annotations.description}}**\r\n{{else}}\r\n[Prometheus告警信息]($v.generatorURL}})\r\n>**[{{$v.labels.alertname}}]({{$var}})**\r\n>告警级别: {{$v.labels.level}}\r\n开始时间: {{$v.startsAt}}\r\n结束时间: {{$v.endsAt}}\r\n故障主机IP: {{$v.labels.instance}}\r\n**{{$v.annotations.description}}**\r\n{{end}}\r\n{{ end }}', '2020-12-22 03:07:19'); + + diff --git a/example/helm/prometheusalert/templates/deployment.yaml b/example/helm/prometheusalert/templates/deployment.yaml index af294a5d..4257c53a 100644 --- a/example/helm/prometheusalert/templates/deployment.yaml +++ b/example/helm/prometheusalert/templates/deployment.yaml @@ -20,6 +20,7 @@ spec: - name: {{ .Chart.Name }} image: "{{ .Values.image.repository }}" imagePullPolicy: {{ .Values.image.pullPolicy }} + command: ['sh', '-c', "sqlite3 /app/db/PrometheusAlertDB.db '.read /app/db/init.sql' && /app/PrometheusAlert"] env: - name: TZ value: "Asia/Shanghai" @@ -34,6 +35,9 @@ spec: - name: prometheus-alert-center-conf mountPath: /app/user.csv subPath: user.csv + - name: prometheus-alert-center-conf + mountPath: /app/db/init.sql + subPath: init.sql livenessProbe: httpGet: path: /health @@ -75,3 +79,5 @@ spec: path: app.conf - key: user.csv path: user.csv + - key: init.sql + path: init.sql diff --git a/example/helm/prometheusalert/values.yaml b/example/helm/prometheusalert/values.yaml index f31035b3..72781c2b 100644 --- a/example/helm/prometheusalert/values.yaml +++ b/example/helm/prometheusalert/values.yaml @@ -5,6 +5,7 @@ replicaCount: 1 image: + # 支持配置自定义模版需要重出镜像,或者使用本人构建镜像:lusson/prometheusalert:v1.0 repository: feiyu563/prometheus-alert:latest pullPolicy: IfNotPresent