You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
56 lines
1.9 KiB
56 lines
1.9 KiB
#!/usr/bin/env bash |
|
|
|
# shellcheck source=/dev/null |
|
source ./env.sh |
|
|
|
logfile=/tmp/kind-get-clusters |
|
|
|
kind get clusters | tee "${logfile}" |
|
|
|
if grep "${CLUSTERNAME}" ${logfile} |
|
then |
|
echo "--- kind delete cluster --name \"${CLUSTERNAME}\"" |
|
kind delete cluster --name "${CLUSTERNAME}" |
|
sleep 30 |
|
fi |
|
|
|
echo "--- podman inspect -f '{{.State.Running}}' \"${REGISTRY_NAME}\"" |
|
podman inspect -f '{{.State.Running}}' "${REGISTRY_NAME}" |
|
if [ "$(podman inspect -f '{{.State.Running}}' "${REGISTRY_NAME}" 2>/dev/null || true)" != 'true' ]; then |
|
podman run \ |
|
-d --restart=always -p "127.0.0.1:${REGISTRY_PORT}:5000" --network bridge --name "${REGISTRY_NAME}" \ |
|
registry:3 |
|
fi |
|
|
|
systemd-run --scope -p "Delegate=yes" --user kind create cluster --config=kind-config.yaml |
|
|
|
for node in $(kind get nodes); do |
|
podman exec "${node}" mkdir -p "${REGISTRY_DIR}" |
|
cat <<EOF | podman exec -i "${node}" cp /dev/stdin "${REGISTRY_DIR}/hosts.toml" |
|
[host."http://${REGISTRY_NAME}:5000"] |
|
EOF |
|
done |
|
|
|
echo "--- podman inspect -f='{{json .NetworkSettings.Networks.kind}}' \"${REGISTRY_NAME}\"" |
|
podman inspect -f='{{json .NetworkSettings.Networks.kind}}' "${REGISTRY_NAME}" |
|
if [ "$(podman inspect -f='{{json .NetworkSettings.Networks.kind}}' "${REGISTRY_NAME}")" = 'null' ] |
|
then |
|
echo "--- podman network connect \"kind\" \"${REGISTRY_NAME}\"" |
|
podman network connect "kind" "${REGISTRY_NAME}" |
|
fi |
|
|
|
cat <<EOF | kubectl apply -f - |
|
apiVersion: v1 |
|
kind: ConfigMap |
|
metadata: |
|
name: local-registry-hosting |
|
namespace: kube-public |
|
data: |
|
localRegistryHosting.v1: | |
|
host: "localhost:${REGISTRY_PORT}" |
|
help: "https://kind.sigs.k8s.io/docs/user/local-registry/" |
|
EOF |
|
|
|
# podman save docker.io/library/registry:3 | xz > /datas/kubernetes/backups/registry.tar.xz |
|
# podman save docker.io/kindest/node@sha256:f226345927d7e348497136874b6d207e0b32cc52154ad8323129352923a3142f | xz > /datas/kubernetes/backups/kindest.tar.xz |
|
# podman pull docker.io/debian:sid |