舵升级失败,“功能”X“未定义”

问题描述 投票:1回答:1

我正在尝试升级舵图,

我得到错误函数“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}}”,

这是我得到的错误:

掌舵升级 - 干运行prometheus-operator-chart / home / ubuntu / infra-devops / helm / vector-chart / prometheus-operator-chart /错误:UPGRADE FAILED:解析错误“prometheus-operator / templates / grafana / dashboards / services-health.yaml“:template:prometheus-operator / templates / grafana / dashboards / services-health.yaml:1213:function”pod“未定义

我试图逃避它,但没有任何效果。任何人都知道如何解决这个问题?

kubernetes kubernetes-helm configmap
1个回答
1
投票

使用backticks可以转义gotpl占位符。例如,在您的场景中,您可以编写{{ pod }}而不是使用{{` {{ pod }} `}}

© www.soinside.com 2019 - 2024. All rights reserved.