0
votes

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
Saying "i want to pass the file ..." did you mean to pass name of this file or content of this file?Matt
Contents of the fileDarshil Shah

1 Answers

5
votes

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 .