-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feature: add scripts for cluster management with k0s, kind, and minik…
…ube (#19) Signed-off-by: Schubert Anselme <[email protected]>
- Loading branch information
Showing
12 changed files
with
109 additions
and
163 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#!/bin/bash | ||
|
||
CONFIG="${1:-hack/cluster.yaml}" | ||
KUBECONFIG="${KUBECONFIG:-hack/kubeconfig.yaml}" | ||
|
||
CONTROLLER_IP_ADDR="$(yq ' | ||
.spec.hosts[] | | ||
select(.role == "controller+worker") | | ||
.ssh.address | ||
' "${CONFIG}")" | ||
CONTROLLER_USER="$(yq ' | ||
.spec.hosts[] | | ||
select(.role == "controller+worker") | | ||
.ssh.user | ||
' "${CONFIG}")" | ||
|
||
# todo: configure containerd (docker login) | ||
cat <<eof >/tmp/prerun.sh | ||
#!/bin/bash | ||
sudo mkdir -p /var/lib/k0s/manifests/crds /var/lib/k0s/pki | ||
sudo touch /var/lib/k0s/pki/admin.conf | ||
stat -f /var/lib/k0s/manifests/crds/external-snapshotter.yaml >/dev/null 2>&1 || | ||
sudo k0s kubectl kustomize https://github.com/kubernetes-csi/external-snapshotter/client/config/crd?ref=v8.1.0 | | ||
sudo tee /var/lib/k0s/manifests/crds/external-snapshotter.yaml >/dev/null 2>&1 | ||
stat -f /var/lib/k0s/manifests/crds/gateway-api.yaml >/dev/null || | ||
sudo k0s kubectl kustomize https://github.com/kubernetes-sigs/gateway-api/config/crd/experimental?ref=v1.2.0 | | ||
sudo tee /var/lib/k0s/manifests/crds/gateway-api.yaml >/dev/null | ||
eof | ||
|
||
# pre-run | ||
scp /tmp/prerun.sh "${CONTROLLER_USER}@${CONTROLLER_IP_ADDR}:/tmp/prerun.sh" | ||
ssh "${CONTROLLER_USER}@${CONTROLLER_IP_ADDR}" chmod +x /tmp/prerun.sh | ||
ssh "${CONTROLLER_USER}@${CONTROLLER_IP_ADDR}" sudo /tmp/prerun.sh | ||
ssh "${CONTROLLER_USER}@${CONTROLLER_IP_ADDR}" rm -f /tmp/prerun.sh | ||
|
||
# create cluster | ||
k0sctl apply --config "${CONFIG}" | ||
|
||
# fixme: export kubeconfig (do not overwrite) | ||
k0sctl kubeconfig --config hack/cluster.yaml >"${KUBECONFIG}" | ||
chmod 0600 "${KUBECONFIG}" | ||
|
||
# post-run | ||
kubectl --kubeconfig "${KUBECONFIG}" cluster-info |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0 | ||
|
||
set -eo pipefail | ||
|
||
# note: kind cluster | ||
kind create cluster --config config/kind.yaml | ||
kustomize build deployment/crd | kubectl apply -f - | ||
|
||
# note: cloud provider | ||
docker container run --rm \ | ||
--network kind \ | ||
-v /var/run/docker.sock:/var/run/docker.sock \ | ||
sanselme/cloud-provider-kind | ||
|
||
# debug: proxy | ||
# docker container run --rm \ | ||
# --name kind-proxy \ | ||
# --network kind \ | ||
# -p 1080:1080 \ | ||
# serjs/go-socks5-proxy@sha256:aad36c623f16850d7cea0171d1aa79d706129191db9e270b6dfd7db6b552c734 | ||
# export ALL_PROXY=socks5://localhost:1080 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/bash | ||
# SPDX-License-Identifier: GPL-3.0 | ||
|
||
set -eo pipefail | ||
|
||
: "${CPUS:=4}" | ||
: "${MEMORY:="16GiB"}" | ||
: "${DISK_SIZE:="64GiB"}" | ||
|
||
# note: | ||
# - minikube starts services that may be available on the Internet. Please ensure that you have a firewall to protect your host from unexpected access. For instance: | ||
# - apiserver listens on TCP *:8443 | ||
# - kubelet listens on TCP *:10250 and *:10255 | ||
# - kube-scheduler listens on TCP *:10259 | ||
# - kube-controller listens on TCP *:10257 | ||
|
||
# debug: Run minikube start --alsologtostderr -v=4 to debug crashes | ||
if grep -E -q 'vmx|svm' /proc/cpuinfo >/dev/null 2>&1; then | ||
export DRIVER="kvm2" | ||
export OPT="--profile=kubevirt --kvm-gpu=false --hidden=true --kvm-network='' --network='' --kvm-qemu-uri=qemu:///system" | ||
else | ||
export DRIVER="qemu" | ||
export OPT="--network=socket_vmnet" | ||
fi | ||
|
||
# note: minikube cluster | ||
minikube config set cpus "${CPUS}" | ||
minikube config set memory "${MEMORY}" | ||
minikube config set disk-size "${DISK_SIZE}" | ||
minikube start \ | ||
--cni=cilium \ | ||
--container-runtime=containerd \ | ||
--docker-opt=containerd=/var/run/containerd/containerd.sock \ | ||
--driver="${DRIVER}" \ | ||
"${OPT}" | ||
|
||
# note: addons | ||
minikube addons enable gvisor | ||
minikube addons enable metrics-server | ||
minikube addons enable volumesnapshots |
This file was deleted.
Oops, something went wrong.