Multi-Node Cluster

Creating a Multi-Node Cluster from a Config File

kind 14,561 create cluster alone builds a one-node cluster called kind. A config file in Git 1,932 gives everyone the same cluster:

k8s/kind-cluster.yaml: BookNest's local clusterYAML
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
name: l3-booknest
networking:
  apiServerAddress: 127.0.0.1
  apiServerPort: 33443
containerdConfigPatches:
- |-
  [plugins."io.containerd.grpc.v1.cri".registry]
    config_path = "/etc/containerd/certs.d"
nodes:
- role: control-plane
  extraPortMappings:
  - { containerPort: 30080, hostPort: 33080, listenAddress: 127.0.0.1 }
- role: worker

name prefixes every node container and the context. apiServerPort fixes the API server's host port, which kind otherwise picks at random on each rebuild. The containerd 234,762 patch enables per-registry settings (Loading Local Images). extraPortMappings publishes the front end's NodePort (Exposing BookNest) like docker run -p, and must be set now, because Docker 514 cannot add ports to a running container. To pin Kubernetes 5,150 , add image: kindest/node:v1.37.0@sha256:... to each node, with the digest from kind's release notes.

Creating BookNest's cluster from the config fileShell
kind create cluster --config k8s/kind-cluster.yaml --quiet
docker ps --filter label=io.x-k8s.kind.cluster=l3-booknest --format '{{.Names}}  {{.Ports}}'
Output
l3-booknest-worker
l3-booknest-control-plane  127.0.0.1:33443->6443/tcp, 127.0.0.1:33080->30080/tcp

Each node is a container on the Docker network kind; only the control plane publishes ports. Creation took about 40 seconds with the node image cached. kind delete cluster --name l3-booknest removes it all again.