如何在舵图中使用值文件传递文件? [英] How to pass a file using values file in helm chart?

查看:70
本文介绍了如何在舵图中使用值文件传递文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将证书传递给头盔图表,当前我正在使用--set-file global.dbValues.dbcacertificate =./server.crt进行传递,但我想将文件传递到头盔图表的值文件中. Values.yaml文件读取

I want to pass a certificate to the helm chart and currently I am passing using --set-file global.dbValues.dbcacertificate=./server.crt but instead i want to pass the file in values file of helm chart. The Values.yaml file reads

global:
  dbValues:
    dbcacertificate: <Some Way to pass the .crt file>

推荐答案

根据相关文档,必须将图表外部的文件预处理为可通过--set--values提供的方式,因为.Files.Get无法读取图表捆绑包外部的文件路径

According to the relevant documentation, one must pre-process a file that is external to the chart into a means that can be provided via --set or --values, since .Files.Get cannot read file paths that are external to the chart bundle.

因此,给出以下示例模板templates/secret.yaml:

So, given the following example template templates/secret.yaml containing:

apiVersion: v1
kind: Secret
data:
  dbcacertificate: {{ .Values.dbcacertificate | b64enc }}

可以将外壳插值用作:

helm template --set dbcacertificate="$(cat ./server.crt)" .

或者,如果外壳插值不适合您的情况,则可以将证书预处理为yaml兼容格式,然后通过--values进行输入:

or, if shell interpolation is not suitable for your circumstances, you can pre-process the certificate into a yaml compatible format and feed it in via --values:

$ { echo "dbcacertificate: |"; sed -e 's/^/    /' server.crt; } > ca-cert.yaml
$ helm template --values ./ca-cert.yaml .

这篇关于如何在舵图中使用值文件传递文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆