Configuring TLS on openshift using helm

Viewed 806

I am trying to configure TLS using edge termination on openshift, am passing the TLS certificates and private key in values.yaml and referring it in route.yaml file, when I execute the helm chart the creation of the route fails due to improper indentation and newlines introduced while copying the certificate from values.yaml to the route.yaml file.

Below are the values.yaml file from which am referring the certificate in the route.yaml file. What is the better way to do this? how can I pass the tls cert and private key from values.yaml with proper indentation.

Values.yaml

route:
  Enabled: true
  annotations:
    haproxy.router.openshift.io/cookie_name: SESSION_XLD
    haproxy.router.openshift.io/disable_cookies: "false"
    haproxy.router.openshift.io/rewrite-target: /
  path: /
  hosts:
    - www.example.com
  tls:
    key:
      -----BEGIN CERTIFICATE-----
      [...]
      -----END CERTIFICATE-----
    certificate:
      -----BEGIN CERTIFICATE-----
      [...]
      -----END CERTIFICATE-----
    caCertificate:
      -----BEGIN CERTIFICATE-----
      [...]
      -----END CERTIFICATE-----
    insecureEdgeTerminationPolicy: Redirect

route.yaml

{{- if $.Values.route.tls }}
  tls:
    termination: edge
  {{- with $.Values.route.tls }}
    key: |
      {{ .key }}
    certificate: |
      {{ .certificate }}
    caCertificate: |
      {{ .caCertificate }}
    insecureEdgeTerminationPolicy: {{ .insecureEdgeTerminationPolicy }}
  {{- end }}
{{- end }}
2 Answers

How about try to pass the each certificate to route.yaml with | for preserving the indentation in Values.yaml either as follows ?

  tls:
    key: | <--- add
      -----BEGIN CERTIFICATE-----
      [...]
      -----END CERTIFICATE-----
    certificate: | <--- add
      -----BEGIN CERTIFICATE-----
      [...]
      -----END CERTIFICATE-----
    caCertificate: | <--- add
      -----BEGIN CERTIFICATE-----
      [...]
      -----END CERTIFICATE-----

add | before certificate like @Daein answer, but also in route yaml add quote certificate: {{ .certificate | quote }}

Related