added some comments and refactored idempotency

This commit is contained in:
root 2023-07-23 21:53:37 -06:00
parent 318f6adc5d
commit f5faecaae4
2 changed files with 36 additions and 33 deletions

View File

@ -5,11 +5,19 @@ export PATH=$PATH:$(go env GOPATH)/bin
reg_name="kind-registry" reg_name="kind-registry"
reg_port="5001" 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 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 podman run -d -p "127.0.0.1:${reg_port}:5000" --name "${reg_name}" registry:2
fi fi
kind get clusters -q | egrep '^ek-demo$' >/dev/null || cat <<EOF | kind create cluster -n ek-demo --image kindest/node:v1.24.15 --kubeconfig .kube/config --config=- # Create cluster, with ingress and registry patches
if [ ! "$(kind get clusters -q | egrep '^ek-demo$' >/dev/nulli)" ]; then
cat <<-EOF | kind create cluster -n ek-demo --image kindest/node:v1.24.15 --kubeconfig .kube/config --config=-
kind: Cluster kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4 apiVersion: kind.x-k8s.io/v1alpha4
containerdConfigPatches: containerdConfigPatches:
@ -35,7 +43,9 @@ nodes:
- role: worker - role: worker
- role: worker - role: worker
EOF EOF
fi
# Add registry to each node
REGISTRY_DIR="/etc/containerd/certs.d/localhost:${reg_port}" REGISTRY_DIR="/etc/containerd/certs.d/localhost:${reg_port}"
for node in $(kind get nodes -q --name staticweb); do for node in $(kind get nodes -q --name staticweb); do
podman exec "${node}" mkdir -p "${REGISTRY_DIR}" podman exec "${node}" mkdir -p "${REGISTRY_DIR}"

View File

@ -1,7 +0,0 @@
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
- role: worker