我正在尝试升级一个helm图表,
我遇到了错误:“函数” pod“未定义”,这很有道理,因为我确实没有这样的函数。
“pod”来自一个json文件,我将其转换为configmap,并且helm将此值读取为函数而不是json文件中的字符串。
这是我的configmap的片段:
# Generated from 'pods' from https://raw.githubusercontent.com/coreos/prometheus-operator/master/contrib/kube-prometheus/manifests/grafana-dashboardDefinitions.yaml
# Do not change in-place! In order to change this file first read following link:
# https://github.com/helm/charts/tree/master/stable/prometheus-operator/hack
{{- if and .Values.grafana.enabled .Values.grafana.defaultDashboardsEnabled }}
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ printf "%s-%s" (include "prometheus-operator.fullname" $) "services-health" | trunc 63 | trimSuffix "-" }}
labels:
{{- if $.Values.grafana.sidecar.dashboards.label }}
{{ $.Values.grafana.sidecar.dashboards.label }}: "1"
{{- end }}
app: {{ template "prometheus-operator.name" $ }}-grafana
{{ include "prometheus-operator.labels" $ | indent 4 }}
data:
services-health.json: |-
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
}
]
},
"targets": [
{
"expr": "{__name__=~\"kube_pod_container_status_ready\", container=\"aggregation\",kubernetes_namespace=\"default\",chart=\"\"}",
"format": "time_series",
"instant": false,
"intervalFactor": 2,
"legendFormat": "{{pod}}",
"refId": "A"
}
}
{{- end }}
我遇到的错误来自这行代码:“legendFormat”:“{{pod}}”, 我收到的错误信息如下:
我尝试了转义字符,但是没有效果。有人有什么想法可以解决这个问题吗?helm upgrade --dry-run prometheus-operator-chart /home/ubuntu/infra-devops/helm/vector-chart/prometheus-operator-chart/ 错误:升级失败:“prometheus-operator/templates/grafana/dashboards/services-health.yaml”中存在解析错误: 模板: prometheus-operator/templates/grafana/dashboards/services-health.yaml:1213: 函数“pod”未定义