diff --git a/charts/prometheusalert/Chart.yaml b/charts/prometheusalert/Chart.yaml index 6ebf9e9..0aaa9ad 100644 --- a/charts/prometheusalert/Chart.yaml +++ b/charts/prometheusalert/Chart.yaml @@ -6,7 +6,7 @@ annotations: - name: Chart Source url: https://github.com/dellnoantechnp.github.io/tree/main/charts/xxl-job-admin apiVersion: v2 -appVersion: 4.9 +appVersion: 4.9.1 name: prometheusalert description: A Alert-Center for Prometheus Grafana and Graylog, alert message deliver to Wechat/Feishu/Lark/email/DingTalk/workWechat/webhook/telegram ... home: https://github.com/feiyu563/PrometheusAlert @@ -18,4 +18,10 @@ maintainers: sources: - https://github.com/feiyu563/PrometheusAlert type: application -version: 1.2.3 \ No newline at end of file +dependencies: + - name: common + repository: oci://registry-1.docker.io/bitnamicharts + tags: + - bitnami-common + version: 2.x.x +version: 1.3.0 \ No newline at end of file diff --git a/charts/prometheusalert/templates/_helpers.tpl b/charts/prometheusalert/templates/_helpers.tpl index fa9c0ec..1a9f275 100644 --- a/charts/prometheusalert/templates/_helpers.tpl +++ b/charts/prometheusalert/templates/_helpers.tpl @@ -53,4 +53,15 @@ AlertmanagerConfig namespace {{- else -}} {{ .Release.Namespace }} {{- end -}} +{{- end -}} + + +{{/* +Return true if a configmap object should be created on values +*/}} +{{- define "app.primary.createConfigmap" -}} +{{- if and .Values.config.app_conf }} + {{- true -}} +{{- else -}} +{{- end -}} {{- end -}} \ No newline at end of file diff --git a/charts/prometheusalert/templates/configmap.yaml b/charts/prometheusalert/templates/configmap.yaml index 973dd79..65a1ab5 100644 --- a/charts/prometheusalert/templates/configmap.yaml +++ b/charts/prometheusalert/templates/configmap.yaml @@ -7,7 +7,7 @@ metadata: data: {{- if .Values.config.app_conf }} app.conf: | -{{ .Values.config.app_conf | indent 4 }} + {{- include "common.tplvalues.render" (dict "value" .Values.config.app_conf "context" $ ) | indent 4 }} {{- end -}} {{- if .Values.config.init_sql }} diff --git a/charts/prometheusalert/templates/deployment.yaml b/charts/prometheusalert/templates/deployment.yaml index a096ee0..69ebfa6 100644 --- a/charts/prometheusalert/templates/deployment.yaml +++ b/charts/prometheusalert/templates/deployment.yaml @@ -32,7 +32,7 @@ spec: value: "Asia/Shanghai" ports: - name: http - containerPort: 8080 + containerPort: {{ .Values.pod.containerPort }} protocol: TCP volumeMounts: - name: prometheus-alert-center-conf @@ -44,26 +44,16 @@ spec: - name: prometheus-alert-center-conf mountPath: /app/db/init.sql subPath: init.sql - livenessProbe: - httpGet: - path: /health - port: http - failureThreshold: 3 - initialDelaySeconds: 10 - periodSeconds: 20 - successThreshold: 1 - timeoutSeconds: 3 - readinessProbe: - httpGet: - path: /health - port: http - failureThreshold: 3 - initialDelaySeconds: 10 - periodSeconds: 20 - successThreshold: 1 - timeoutSeconds: 3 + {{- if .Values.pod.livenessProbe }} + livenessProbe: {{ toYaml .Values.pod.livenessProbe | nindent 12 }} + {{- end }} + {{- if .Values.pod.readinessProbe }} + readinessProbe: {{ toYaml .Values.pod.readinessProbe | nindent 12 }} + {{- end }} + {{- if or (hasKey .Values.pod.resources "requests") (hasKey .Values.pod.resources "limits") }} resources: - {{- toYaml .Values.resources | nindent 12 }} + {{- toYaml .Values.pod.resources | nindent 12 }} + {{- end }} {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/charts/prometheusalert/values.yaml b/charts/prometheusalert/values.yaml index f93212b..5a8208a 100644 --- a/charts/prometheusalert/values.yaml +++ b/charts/prometheusalert/values.yaml @@ -17,6 +17,37 @@ nameOverride: "" fullnameOverride: "" +pod: + containerPort: 8000 + + livenessProbe: + httpGet: + path: /health + port: http + failureThreshold: 3 + initialDelaySeconds: 10 + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 3 + readinessProbe: + httpGet: + path: /health + port: http + failureThreshold: 3 + initialDelaySeconds: 10 + periodSeconds: 20 + successThreshold: 1 + timeoutSeconds: 3 + + resources: {} + #resources: + # limits: + # cpu: 500m + # memory: 512Mi + # requests: + # cpu: 10m + # memory: 128Mi + service: type: ClusterIP port: 8080 @@ -31,13 +62,6 @@ ingress: paths: ["/"] tls: [] -resources: - limits: - cpu: 500m - memory: 512Mi - requests: - cpu: 10m - memory: 128Mi ## @param affinity Affinity for pod assignment ## Ref: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/#affinity-and-anti-affinity @@ -194,7 +218,7 @@ config: #监听地址 httpaddr = "0.0.0.0" #监听端口 - httpport = 8080 + httpport = {{ .Values.pod.containerPort | default "8000" }} # 运行模式 dev|prod runmode = dev #设置代理 proxy = http://123.123.123.123:8080 @@ -218,7 +242,7 @@ config: #故障恢复是否启用电话通知0为关闭,1为开启 phonecallresolved=0 #是否前台输出file or console - logtype=file + logtype=console #日志文件路径 logpath=logs/prometheusalertcenter.log #转换Prometheus,graylog告警消息的时区为CST时区(如默认已经是CST时区,请勿开启) @@ -490,7 +514,7 @@ config: INSERT INTO prometheus_alert_d_b (id, tpltype, tpluse, tplname, tpl, created) VALUES (1, 'dd', 'Prometheus', 'prometheus-dd', '{{ $var := .externalURL}} {{ range $k,$v:=.alerts }} {{if eq $v.status "resolved"}} - ## **Prometheus 恢复通知** + ## **Prometheus 恢复通知** --- * 🟡【告警名称】{{$v.labels.alertname}} * 🚨【告警级别】{{ $v.labels.severity}} @@ -498,8 +522,8 @@ config: * 🧭【开始时间】{{GetCSTtime $v.startsAt}} * 🧭【结束时间】{{GetCSTtime $v.endsAt}} * 🏷️【命名空间】{{$v.labels.namespace}} - * 📡【实例名称】{{$v.labels.host}}{{$v.labels.pod}}{{$v.labels.job}}{{$v.labels.deployment}}{{$v.labels.statefulset}} - * 📝【告警详情】{{ $v.annotations.message }}{{ $v.annotations.description}};{{$v.annotations.summary}} + * 📡【实例名称】{{$v.labels.host}}/{{$v.labels.pod}}/{{$v.labels.job}}/{{$v.labels.deployment}}/{{$v.labels.statefulset}} + * 📝【告警详情】{{ $v.annotations.message }}/{{ $v.annotations.description}};{{$v.annotations.summary}} {{else}} ## **Prometheus 告警通知** --- @@ -508,8 +532,8 @@ config: * 🔥【告警状态】{{$v.status}} * 🧭【开始时间】{{GetCSTtime $v.startsAt}} * 🏷️【命名空间】{{$v.labels.namespace}} - * 📡【实例名称】{{$v.labels.host}}{{$v.labels.pod}}{{$v.labels.job}}{{$v.labels.deployment}}{{$v.labels.statefulset}} - * 📝【告警详情】{{ $v.annotations.message }}{{ $v.annotations.description}};{{$v.annotations.summary}} + * 📡【实例名称】{{$v.labels.host}}/{{$v.labels.pod}}/{{$v.labels.job}}/{{$v.labels.deployment}}/{{$v.labels.statefulset}} + * 📝【告警详情】{{ $v.annotations.message }}/{{ $v.annotations.description}};{{$v.annotations.summary}} {{ end }} {{ end }} {{ $urimsg:="" }}