added some comments and refactored idempotency
This commit is contained in:
parent
318f6adc5d
commit
f5faecaae4
@ -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 <<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
|
||||
# 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
|
||||
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}"
|
||||
|
Loading…
Reference in New Issue
Block a user