kubernetes - 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 错误有什么问题?
解决方案
您想使用 .Files.Get 加载 yaml 文件或获取 yaml 文件中的 yaml 内容并将其捕获到 values.yaml 中,以便您可以使用 toYaml 将其直接插入到配置映射中。
如果这些值只是静态的并且您不需要用户覆盖它们,那么 .Files.Get 更适合您。如果您希望能够在安装时轻松覆盖 yaml 文件中的内容,那么只需在 values.yaml 文件中表示它们即可。
推荐阅读
- arrays - Typescript 与数组对象的映射关系
- solr - 具有 Wordnet 格式的同义词文件的同义词图过滤器不起作用
- javascript - 检查是否加载了 iframe 内容?
- math - Gnuplot - 函数
- python - 在 R 或 Python 中使用 If Else 语句创建组、中断和条件
- bash - 在 Bash Mac 中不换行
- c# - C# Windows 窗体,MySQL 已经运行错误
- mysql - NiFi ExecuteSqlRecord 不处理 SQL 查询(Presto)
- r - pkgdown 一些显示 404 的参考资料,并且自述文件上的图像未显示在主页上
- rxjs - rxjs TypeError:this._complete 不是函数