Skip to content

Instantly share code, notes, and snippets.

@ezodude
Forked from victorpaulo/kind-with-registry.sh
Created November 12, 2021 22:20
Show Gist options
  • Save ezodude/cc51b32275c6925ae90e1cace57491ef to your computer and use it in GitHub Desktop.
Save ezodude/cc51b32275c6925ae90e1cace57491ef 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