i've came across 2 types of syntax for creating configmaps from files in kubernetes.
first one ;
apiVersion: v1
data:
file1.yaml: |+
parameter1=value1
kind: ConfigMap
metadata:
name: my-configmap
second one ;
apiVersion: v1
data:
file1.yaml: | -
parameter1=value1
kind: ConfigMap
metadata:
name: my-configmap
what is the difference between |+ and |- ?
This is the block chomping indicator.
Directly quoting from the link:
The chomping indicator controls what should happen with newlines at the end of the string. The default, clip, puts a single newline at the end of the string. To remove all newlines, strip them by putting a minus sign (-) after the style indicator. Both clip and strip ignore how many newlines are actually at the end of the block; to keep them all put a plus sign (+) after the style indicator.
This means that for:
apiVersion: v1
data:
file1.yaml: |-
parameter1=value1
kind: ConfigMap
metadata:
name: my-configmap
file1.yaml will have the value:
parameter1=value1
For:
apiVersion: v1
data:
file1.yaml: |+
parameter1=value1
kind: ConfigMap
metadata:
name: my-configmap
file1.yaml will have the value:
parameter1=value1 # line break
# line break
# line break
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With