【问题标题】:Helm error `error calling index: value is nil; should be of type string` when this error did not appear beforeHelm error`错误调用索引:值为nil;当此错误之前未出现时,应为 string` 类型
【发布时间】:2022-11-07 18:36:42
【问题描述】:

我一直在毫无问题地部署我的代码;但是,我现在在从终端部署时收到以下错误:

<index .Values.common .Values.deploy_target>: error calling index: value is nil; should be of type string

这是我的代码以获得更好的主意。我有我的deployment.yamlValues.yml。这是代码的摘录:

deployment.yaml

          # Common Environment variables
          {{- with (index .Values.common .Values.deploy_target) }}
            {{- range .env_vars }}
            - name: {{.name}}
              value: "{{.value}}"
            {{- end }}
          {{- end }}

values.yaml

common:
  dev:
    env_vars:
      - name: foo
        value: bar
      - name: foo
        value: bar
  qa:
    env_vars:
      - name: foo
        value: bar
      - name: foo
        value: bar
  production:
    env_vars:
      - name: foo
        value: bar
      - name: foo
        value: bar

我用来安装服务的命令如下:

helm upgrade --install foo-bar .helm/folder -n beta

我会很感激任何可以帮助我的人。

【问题讨论】:

    标签: kubernetes-helm


    【解决方案1】:

    流逻辑看起来是正确的,但似乎 .Values.deploy_target 未在您的 values.yaml 中设置,这就是为什么它在期望字符串时为 nil 的原因。确保.Values.deploy_target 存在。

    旁注:您也可以使用管道而不是在周围放置引号 -> value: {{.value | quote}}

    【讨论】:

    • 谢谢JasonY,让我试试这个。
    猜你喜欢
    • 1970-01-01
    • 2021-08-25
    • 1970-01-01
    • 1970-01-01
    • 2021-12-16
    • 2015-02-02
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多