From 3602c3b42eb3ee2788dd32527aac4ddc933eecaa Mon Sep 17 00:00:00 2001 From: Pavlos Tzianos Date: Mon, 29 Jan 2024 16:50:54 +0000 Subject: [PATCH] Add script for setting up KiND cluster --- scripts/kind-with-registry.sh | 77 +++++++++++++++++++++++++++++++++++ 1 file changed, 77 insertions(+) create mode 100755 scripts/kind-with-registry.sh diff --git a/scripts/kind-with-registry.sh b/scripts/kind-with-registry.sh new file mode 100755 index 000000000..404b8606c --- /dev/null +++ b/scripts/kind-with-registry.sh @@ -0,0 +1,77 @@ +#!/bin/bash + +# based on the script from KiND docs + +set -o errexit + +reg_name='kind-registry' +reg_port='5001' +cluster_name='dracon-demo' + +source ./scripts/util.sh + +while getopts n:p:c: flag +do + case "${flag}" in + u) reg_name=${OPTARG};; + p) reg_port=${OPTARG};; + c) cluster_name=${OPTARG};; + *) util::error "unknown flag ${flag}"; exit 1;; + esac +done + +# 1. Create registry container unless it already exists +if [ "$(docker inspect -f '{{.State.Running}}' ${reg_name} 2>/dev/null)" != "true" ] +then + util::info "Spinning up container with Docker registry" + docker run --detach \ + --restart=always \ + --publish "127.0.0.1:${reg_port}:5000" \ + --network bridge \ + --name "${reg_name}" \ + registry:2 +fi + +# 2. Create kind cluster with containerd registry config dir enabled +if ! $(kind get clusters 2>&1 | grep "${cluster_name}") +then + cat <