Answer a question

Following this tutorial to connect a local docker registry to the KIND cluster there's the below chunk of code in the bash script. I want to use my config file, but I don't know how the below chunk fits in (there's a lot of dashes and pipes in the syntax).

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}:${reg_port}"]
EOF

My config file:

kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
  extraPortMappings:
  - containerPort: 8080
    hostPort: 80
    protocol: TCP
- role: worker
- role: worker
- role: worker
- role: worker

Answers

In the shell fragment you show, everything between the first and last lines, including the dashes and pipes, is a valid YAML file; the only processing the shell does is replacing ${reg_name} and ${reg_port} with the values of the corresponding environment variables.

If you want to merge this with your existing kind config file, you should be able to just combine the top-level keys:

apiVersion: kind.x-k8s.io/v1alpha4
kind: Cluster
nodes:
- role: control-plane
  et: cetera
containerdConfigPatches:
- |-
  [plugins."io.containerd.grpc.v1.cri".registry.mirrors."localhost:5000"]
    endpoint = ["http://kind-registry:5000"]

If you had other containerdConfigPatches, the sequence of items starting with - on each line is a YAML list (like you have in nodes:) and you could add this patch to the end of the list. (This is a little unlikely since this option isn't documented in the kind Configuration documentation.)

Logo

K8S/Kubernetes社区为您提供最前沿的新闻资讯和知识内容

更多推荐