vi <template-name>
内容如下:
apiVersion: v1
data:
template: |
{{- define "nm.default.markdown.test" }}
{{- range .Alerts }}
{{- $rawStatus := .Status }}
{{- if eq $rawStatus "firing" }}
### <font color="yellow">{{ template "nm.default.message" . }}</font>
{{- else }}
### <font color="green">{{ template "nm.default.message" . }}</font>
{{- end }}
{{- range .Labels.SortedPairs }}
{{- if eq .Name "severity" }}
{{- $color := "" }}
{{- if eq .Value "critical" }}
{{- $color = "red" }}
{{- else if eq .Value "error" }}
{{- $color = "orange" }}
{{- else if eq .Value "warning" }}
{{- $color = "yellow" }}
{{- else if eq .Value "info" }}
{{- $color = "blue" }}
{{- end }}
> <font color="{{$color}}">**{{ .Name | translate }}: {{ .Value }}**</font>
{{- else }}
> **{{ .Name | translate }}**: {{ .Value }}
{{- end }}
{{- end }}
{{ range .Annotations.SortedPairs.Filter "runbook_url" "message" "summary" "summary_cn" }}
> **{{ .Name | translate }}**: {{ .Value }}
{{- end }}
{{ end }}
{{- end }}
kind: ConfigMap
metadata:
name: notification-manager-template-test
namespace: kubesphere-monitoring-system