In this example (link), it creates kind cluster with config file, which patch containerd. What does the - |-
under the line of containerdConfigPatches
mean?
I found - |
in yaml indicates this is a patch field. But what does the -
following - |
mean?
# create a cluster with the local registry enabled in containerd
cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:${reg_port}"]
endpoint = ["http://${reg_name}:5000"]
EOF
|-
introduces a YAML block scalar, a way of writing a multi-line string. The |
means that newlines are preserved (>
would fold the string into a single line), and the -
means the new line at the end is removed.
anywhere: |-
This is a multi-line string. The new
line in the middle is preserved.
The -
at the start of the line (the space is important) is a YAML block sequence (list). This is the same way other lists are presented; for example
listOfStrings:
- one
- two
- three
The - |-
is nothing more than combining these two things: it is a list item whose value is a multi-line string.