yaml 补丁文件中 - |- 是什么意思

Mik*_*ike 0 yaml kubernetes kind

在此示例(链接)中,它使用配置文件创建类型集群,该配置文件修补了containerd。- |-下划线是什么containerdConfigPatches 意思?

我发现- | yaml 表明这是一个补丁字段。但-下面这句话是什么- |意思呢?

# 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
Run Code Online (Sandbox Code Playgroud)

Dav*_*aze 5

|-引入了 YAML块标量,这是一种编写多行字符串的方法。意味着|保留换行符(>将字符串折叠成一行),意味着-末尾的新行被删除。

anywhere: |-
  This is a multi-line string.  The new
  line in the middle is preserved.
Run Code Online (Sandbox Code Playgroud)

行开头- (空格很重要)是 YAML块序列(列表)。这与其他列表的呈现方式相同;例如

listOfStrings:
  - one
  - two
  - three
Run Code Online (Sandbox Code Playgroud)

无非- |-就是将这两件事结合起来:它是一个列表项,其值为多行字符串。