首页 > 解决方案 > Helm lint 错误,但对我来说一切正常

问题描述

整理我的 helm 项目时出现此错误

$ helm lint --debug                                
==> Linting .
[INFO] Chart.yaml: icon is recommended
[ERROR] templates/: render error in "myProject/templates/configmap.yaml": template: myProject/templates/configmap.yaml:26:27: executing "myProject/templates/configmap.yaml" at <.Values.fileServiceH...>: can't evaluate field fileHost in type interface {}

Error: 1 chart(s) linted, 1 chart(s) failed

这是我的configmap.yaml

apiVersion: v1
kind: ConfigMap
metadata:
  name: myProject-configmap

data:
  tkn.yaml: |
    iss: "{{ .Values.iss }}"
    aud: "{{ .Values.aud }}"
  db.yaml: |
    database: "{{ .Values.database }}"
    user: "{{ .Values.user }}"
    host: "{{ .Values.host }}"
    dialect: "{{ .Values.dialect }}"
    pool:
      min: "{{ .Values.pool.min }}"
      max: "{{ .Values.pool.max }}"
      acquire: "{{ .Values.pool.acquire }}"
      idle: "{{ .Values.pool.idle }}"
  fileservice.yaml: |
    fileServiceHost:
      fileHost: "{{ .Values.fileServiceHost.fileHost }}"
  notificationservice.yaml: |
    notificationServiceHost:
      notificationHost: "{{ .Values.notificationservice.notificationHost }}"
  organizationservice.yaml: |
    organizationServiceHost:
      organizationHost: "{{ .Values.organizationservice.organizationHost }}"
  organizations.yaml: |
    organizations: {{ .Values.organizations | toJson | indent 4 }}
  epic.yaml: |
    redirectUri: "{{ .Values.redirectUri }}"

这是我的/vars/dev/fileservice.yaml文件

fileServiceHost:
  fileHost: 'https://example.com'

我收到此 lint 错误有什么问题?

标签: kuberneteskubernetes-helm

解决方案


您想使用 .Files.Get 加载 yaml 文件或获取 yaml 文件中的 yaml 内容并将其捕获到 values.yaml 中,以便您可以使用 toYaml 将其直接插入到配置映射中。

如果这些值只是静态的并且您不需要用户覆盖它们,那么 .Files.Get 更适合您。如果您希望能够在安装时轻松覆盖 yaml 文件中的内容,那么只需在 values.yaml 文件中表示它们即可。


推荐阅读