Skip to content

Instantly share code, notes, and snippets.

@victorpaulo
Created August 12, 2020 14:09
Show Gist options
  • Save victorpaulo/257c5778ebc0bf92fcd9ac5c75f84d4a to your computer and use it in GitHub Desktop.
Save victorpaulo/257c5778ebc0bf92fcd9ac5c75f84d4a to your computer and use it in GitHub Desktop.
KinD cluster creation
#!/bin/sh
set -o errexit
# create registry container unless it already exists
reg_name='kind-registry'
reg_port='5000'
running="$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)"
if [ "${running}" != 'true' ]; then
docker run \
-d --restart=always -p "${reg_port}:5000" --name "${reg_name}" \
registry:2
fi
# create a cluster with the local registry enabled in containerd
cat <<EOF | kind create cluster --config=-
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
extraMounts:
- hostPath: /Users/victorp/projects/kind
containerPath: /data
- role: worker
extraMounts:
- hostPath: /Users/victorp/projects/kind
containerPath: /data
- role: worker
extraMounts:
- hostPath: /Users/victorp/projects/kind
containerPath: /data
containerdConfigPatches:
- |-
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."${reg_name}:${reg_port}"]
endpoint = ["http://${reg_name}:${reg_port}"]
EOF
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment