0

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
Mike
  • 1,841
  • 2
  • 18
  • 34
  • Does this answer your question? [What is does the pipe {'|'} mean in a configmap?](https://stackoverflow.com/questions/73082115/what-is-does-the-pipe-mean-in-a-configmap) – Blender Fox Mar 07 '23 at 19:21

1 Answers1

3

|- 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.

David Maze
  • 130,717
  • 29
  • 175
  • 215