34 lines
757 B
Bash
Executable File
34 lines
757 B
Bash
Executable File
#!/bin/sh
|
|
|
|
: ${CLUSTER_NAME:=krc-tests}
|
|
: ${XDG_RUNTIME_DIR:=/run/user/$(id -u)}
|
|
|
|
: "${DOCKER_HOST=unix://${XDG_RUNTIME_DIR}/podman/podman.sock}"
|
|
: "${DOCKER_SOCK=${XDG_RUNTIME_DIR}/podman/podman.sock}"
|
|
export DOCKER_HOST DOCKER_SOCK
|
|
|
|
cluster_exists() {
|
|
k3d cluster get "${CLUSTER_NAME}" >/dev/null 2>&1
|
|
}
|
|
|
|
create_cluster() {
|
|
k3d cluster create "${CLUSTER_NAME}" \
|
|
--k3s-arg '--kubelet-arg=feature-gates=KubeletInUserNamespace=true@server:*' \
|
|
--kubeconfig-update-default=false \
|
|
--kubeconfig-switch-context=false \
|
|
--no-lb \
|
|
>&2
|
|
}
|
|
|
|
start_cluster() {
|
|
k3d cluster start "${CLUSTER_NAME}" >&2
|
|
}
|
|
|
|
if ! cluster_exists; then
|
|
create_cluster
|
|
else
|
|
start_cluster
|
|
fi
|
|
|
|
k3d kubeconfig write "${CLUSTER_NAME}"
|