【问题标题】:Helm Templating nil pointerHelm 模板 nil 指针
【发布时间】:2021-01-26 19:26:01
【问题描述】:

这是我准备的模板,但它给出了错误。这是我在准备和打印这个 helm 时遇到的错误,我无法从 values.yaml 文件中读取这里的字符

virtual-service.yaml

{{ $prefix := .Values.virtualservice.prefix }}
{{ $uri := .Values.virtualservice.uri }}
apiVersion: v1
items:
- apiVersion: networking.istio.io/v1alpha3
  kind: VirtualService
  metadata:
    name: {{ .Values.deploy.svc.name }}-virtual-service
    namespace: {{ .Values.deploy.namespace }}
  spec:
    gateways:
    - istio-system/istio-gateway
    hosts:
    - {{ .Values.ingress.hosts }}
    http:
    - match:
      - uri:
          prefix: {{ $prefix }}
      rewrite:
        uri: {{ $uri }}
      route:
      - destination:
          host: {{ .Values.deploy.svc.name }}-service
          port:
            number: 80

values.yaml

virtualservice:
  enabled: true
  prefix: v1
  uri: /

Helm 版本:

Client: &version.Version{SemVer:"v2.15.2", GitCommit:"8dce272473e5f2a7bf58ce79bb5c3691db54c96b", GitTreeState:"clean"}
Server: &version.Version{SemVer:"v2.15.2", GitCommit:"8dce272473e5f2a7bf58ce79bb5c3691db54c96b", GitTreeState:"clean"}

错误

Error: render error in "helm/templates/virtual-service.yaml": template: helm/templates/virtual-service.yaml:1:21: executing "helm/templates/virtual-service.yaml" at <.Values.virtualservice.prefix>: nil pointer evaluating interface {}.prefix```

【问题讨论】:

    标签: kubernetes kubernetes-helm


    【解决方案1】:

    Helm 抱怨未解析的变量 virtualservice.uri(在第一行)。您需要将其添加到 values.yaml 或将其传递给 helm 调用,例如:

    helm template [NAME] [CHART] --set virtualservice.uri="whatever"
    

    【讨论】:

      猜你喜欢
      • 2021-09-13
      • 1970-01-01
      • 2011-02-07
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多