diff --git a/hack/kind-up.sh b/hack/kind-up.sh index 1bf70216..035eeab2 100755 --- a/hack/kind-up.sh +++ b/hack/kind-up.sh @@ -8,6 +8,15 @@ set -euo pipefail ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" cd "${ROOT}" +# create registry container unless it already exists +reg_name='kind-registry.local' +reg_port='5000' +if [ "$(docker inspect -f '{{.State.Running}}' "${reg_name}" 2>/dev/null || true)" != 'true' ]; then + docker run \ + -d --restart=always -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" \ + registry:2 +fi + if [[ "${PINNIPED_USE_CONTOUR:-}" != "" ]]; then echo "Adding Contour port mapping to Kind config." ytt -f "${ROOT}/hack/lib/kind-config/single-node.yaml" \ @@ -18,3 +27,23 @@ else # To debug the kind config, add this option to the command below: `-v 10` kind create cluster --config "hack/lib/kind-config/single-node.yaml" --name pinniped fi + + +# connect the registry to the cluster network if not already connected +if [ "$(docker inspect -f='{{json .NetworkSettings.Networks.kind}}' "${reg_name}")" = 'null' ]; then + docker network connect "kind" "${reg_name}" +fi + +# Document the local registry +# https://github.com/kubernetes/enhancements/tree/master/keps/sig-cluster-lifecycle/generic/1755-communicating-a-local-registry +cat <> /etc/hosts\"" +log_note "When you are finished with your Kind cluster, you can remove these lines from /etc/hosts."