Prometheus rule support
This commit is contained in:
@@ -4,7 +4,7 @@ metadata:
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{ include "helm-chart.labels" . | nindent 4 }}
|
||||
{{- include "helm-chart.labels" . | nindent 4 }}
|
||||
spec:
|
||||
schedule: {{ .Values.schedule | quote }}
|
||||
successfulJobsHistoryLimit: 1
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
suite: test deployment
|
||||
suite: test cron job
|
||||
templates:
|
||||
- cronJob.yaml
|
||||
- configmap.yaml
|
||||
|
||||
@@ -15,4 +15,4 @@ type: application
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.5.1
|
||||
version: 0.6.0
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
{{- if .Values.prometheusRules }}
|
||||
apiVersion: monitoring.coreos.com/v1
|
||||
kind: PrometheusRule
|
||||
metadata:
|
||||
name: {{ .Release.Name }}
|
||||
namespace: {{ .Release.Namespace }}
|
||||
labels:
|
||||
{{- include "helm-chart.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
spec:
|
||||
groups:
|
||||
- name: kubernetes-apps
|
||||
rules:
|
||||
{{- range $rule := .Values.prometheusRules }}
|
||||
- alert: {{ $rule.name }}
|
||||
annotations:
|
||||
message: {{ $rule.message | quote }}
|
||||
runbook_url: {{ $rule.runBookURL | quote }}
|
||||
expr: {{ $rule.expression | quote }}
|
||||
for: {{ $rule.for | quote }}
|
||||
labels:
|
||||
{{- toYaml $rule.labels | nindent 12 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
@@ -0,0 +1,24 @@
|
||||
suite: test prometheus rule
|
||||
templates:
|
||||
- prometheus-rule.yaml
|
||||
tests:
|
||||
- it: Should set rules
|
||||
set:
|
||||
prometheusRules:
|
||||
- name: KubePodCrashLooping
|
||||
message: Pod {{`{{`}} $labels.namespace {{`}}`}}/{{`{{`}} $labels.pod {{`}}`}} ({{`{{`}} $labels.container {{`}}`}}) is restarting {{`{{`}} printf "%.2f" $value {{`}}`}} times / 5 minutes.
|
||||
runBookURL:
|
||||
expression: rate(kube_pod_container_status_restarts_total{job="kube-state-metrics", namespace=~"{{ $targetNamespace }}"}[15m]) * 60 * 5 > 0
|
||||
for: 1h
|
||||
labels:
|
||||
severity: criticalv
|
||||
asserts:
|
||||
- equal:
|
||||
path: spec.groups[0].name
|
||||
value: kubernetes-apps
|
||||
- equal:
|
||||
path: spec.groups[0].rules[0].alert
|
||||
value: KubePodCrashLooping
|
||||
- equal:
|
||||
path: spec.groups[0].rules[0].expr
|
||||
value: rate(kube_pod_container_status_restarts_total{job="kube-state-metrics", namespace=~"{{ $targetNamespace }}"}[15m]) * 60 * 5 > 0
|
||||
Reference in New Issue
Block a user