I have defined this below variable in yaml file using literal block scalar and want to refer them in kubernetes ingress file but it is showing |- in output.
Variable file:
domain_ingress:
annotations: |
kubernetes.io/ingress.class: nginx-domain
nginx.ingress.kubernetes.io/ssl-ciphers: "HIGH:!SSLv2:!SSLv3:!DH:!RSA"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
Kubernetes Ingress file:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: {{ env }}-domain-services-ingress
annotations:
{{ domain_ingress.annotations | to_nice_yaml }}
Output is:
---
apiVersion: extensions/v1beta1
kind: Ingress
metadata:
name: infra2-domain-services-ingress
annotations:
|- <why this |- is coming in output>
kubernetes.io/ingress.class: nginx-domain
nginx.ingress.kubernetes.io/ssl-ciphers: "HIGH:!SSLv2:!SSLv3:!DH:!RSA"
nginx.ingress.kubernetes.io/ssl-redirect: "true"
nginx.ingress.kubernetes.io/rewrite-target: /
Using helm template approach I would suggest to remove from your variable file - pipe (|)
as your key annotations: was followed by | : Block scalar indicator
When a string contains line breaks, you can use the literal style, indicated by the pipe (|), to indicate that the string will span several lines.
This approach is used f.e. in ConfigMaps templates instead.
Please let me know if it helped.