From f5faecaae451de36b8884157df8d4b2b54920d92 Mon Sep 17 00:00:00 2001 From: root Date: Sun, 23 Jul 2023 21:53:37 -0600 Subject: [PATCH] added some comments and refactored idempotency --- kind-with-registry.sh | 62 +++++++++++++++++++++++++------------------ kind.yaml | 7 ----- 2 files changed, 36 insertions(+), 33 deletions(-) delete mode 100644 kind.yaml diff --git a/kind-with-registry.sh b/kind-with-registry.sh index 922764b..fd6f80e 100755 --- a/kind-with-registry.sh +++ b/kind-with-registry.sh @@ -5,37 +5,47 @@ export PATH=$PATH:$(go env GOPATH)/bin reg_name="kind-registry" reg_port="5001" +# Build utility image if it doesn't already exist +if [ "$(podman image list --format='{{.Repository}}:{{.Tag}}' 2>/dev/null | cut -d/ -f2 | tr '[:upper:]' '[:lower:]' | egrep 'utility:latest')" != 'utility:latest' ]; then + podman build -t utility . +fi + +# Deploy local registry container if [ "$(podman inspect -f '{{.State.Running}}' ${reg_name} 2>/dev/null || true)" != 'true' ]; then podman run -d -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" registry:2 fi -kind get clusters -q | egrep '^ek-demo$' >/dev/null || cat </dev/nulli)" ]; then + cat <<-EOF | kind create cluster -n ek-demo --image kindest/node:v1.24.15 --kubeconfig .kube/config --config=- + kind: Cluster + apiVersion: kind.x-k8s.io/v1alpha4 + containerdConfigPatches: + - |- + [plugins."io.containerd.grpc.v1.cri".registry] + config_path = "/etc/containerd/certs.d" + nodes: + - role: control-plane + kubeadmConfigPatches: + - | + kind: InitConfiguration + nodeRegistration: + kubeletExtraArgs: + node-labels: "ingress-ready=true" + extraPortMappings: + - containerPort: 80 + hostPort: 80 + protocol: TCP + - containerPort: 443 + hostPort: 443 + protocol: TCP + - role: worker + - role: worker + - role: worker + EOF +fi +# Add registry to each node REGISTRY_DIR="/etc/containerd/certs.d/localhost:${reg_port}" for node in $(kind get nodes -q --name staticweb); do podman exec "${node}" mkdir -p "${REGISTRY_DIR}" diff --git a/kind.yaml b/kind.yaml deleted file mode 100644 index 2509664..0000000 --- a/kind.yaml +++ /dev/null @@ -1,7 +0,0 @@ -kind: Cluster -apiVersion: kind.x-k8s.io/v1alpha4 -nodes: -- role: control-plane -- role: worker -- role: worker -- role: worker