73 lines
3.0 KiB
Bash
Executable File
73 lines
3.0 KiB
Bash
Executable File
#!/usr/bin/env bash
|
|
set -o errexit
|
|
export PATH=$PATH:$(go env GOPATH)/bin
|
|
|
|
reg_name="kind-registry"
|
|
reg_port="5001"
|
|
|
|
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
|
|
|
|
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}"
|
|
cat <<EOF | podman exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml"
|
|
[host."http://${reg_name}:5000"]
|
|
EOF
|
|
done
|
|
|
|
if [ "$(podman inspect -f='{{json .NetworkSettings.Networks.kind}}' ${reg_name})" = 'null' ]; then
|
|
podman network connect "kind" "${reg_name}"
|
|
fi
|
|
|
|
cat <<EOF | podman run -i --net host -h utility -v .kube/:/root/.kube/:Z -v ./:/work:Z -w /work utility kubectl apply -f -
|
|
apiVersion: v1
|
|
kind: ConfigMap
|
|
metadata:
|
|
name: local-registry-hosting
|
|
namespace: kube-public
|
|
data:
|
|
localRegistryHosting.v1: |
|
|
host: "localhost:${reg_port}"
|
|
help: "https://kind.sigs.k8s.io/docs/user/local-registry/"
|
|
EOF
|
|
|
|
podman run -i --net host -h utility -v .kube/:/root/.kube/:Z -v ./:/work:Z -w /work utility kubectl apply -f https://raw.githubusercontent.com/metallb/metallb/v0.13.7/config/manifests/metallb-native.yaml
|
|
podman run -i --net host -h utility -v .kube/:/root/.kube/:Z -v ./:/work:Z -w /work utility kubectl wait --namespace metallb-system --for=condition=ready pod --selector=app=metallb --timeout=90s
|
|
export RANGESTART=$(podman network inspect -f '{{range .Subnets}}{{if eq (len .Subnet.IP) 4}}{{.Subnet}}{{end}}{{end}}' kind | cut -d. -f1-3)
|
|
cat metallb.templ | envsubst | podman run -i --net host -h utility -v .kube/:/root/.kube/:Z -v ./:/work:Z -w /work utility kubectl apply -f -
|
|
|
|
|
|
podman run -i --net host -h utility -v .kube/:/root/.kube/:Z -v ./:/work:Z -w /work utility kubectl apply -f https://projectcontour.io/quickstart/contour.yaml
|
|
|
|
podman run -i --net host -h utility -v .kube/:/root/.kube/:Z -v ./:/work:Z -w /work utility kubectl patch daemonsets -n projectcontour envoy -p '{"spec":{"template":{"spec":{"nodeSelector":{"ingress-ready":"true"},"tolerations":[{"key":"node-role.kubernetes.io/control-plane","operator":"Equal","effect":"NoSchedule"},{"key":"node-role.kubernetes.io/master","operator":"Equal","effect":"NoSchedule"}]}}}}'
|
|
|