How to pass a file using values file in helm chart?

拥有回忆 提交于 2020-06-17 09:15:14

问题


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>

回答1:


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.

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

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

one can use shell interpolation as:

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

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 .


来源:https://stackoverflow.com/questions/60407515/how-to-pass-a-file-using-values-file-in-helm-chart

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!