Skip to content

Instantly share code, notes, and snippets.

@leshikus
Created April 4, 2025 07:54
Show Gist options
  • Save leshikus/c01408224104ea029e6194a5c9a3c227 to your computer and use it in GitHub Desktop.
Save leshikus/c01408224104ea029e6194a5c9a3c227 to your computer and use it in GitHub Desktop.
Install multi-node k8s via kind locally
#!/bin/sh
set -e
set_env() {
arch=amd64
cluster_name=k8s-test
}
install_exec() {
url="$1"
name=${2:-$(basename "$url")}
which "$name" && return 0
curl -L -o "$name" "$url"
chmod u+x "$name"
sudo mv "$name" /usr/local/bin
}
install_helm() {
which helm && return 0
curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod u+x get_helm.sh
./get_helm.sh
}
create_cluster() {
cat > kind-config.yaml <<EOF
kind: Cluster
apiVersion: kind.x-k8s.io/v1alpha4
nodes:
- role: control-plane
- role: worker
- role: worker
EOF
kind create cluster --name $cluster_name --config kind-config.yaml
kubectl get nodes
}
delete_cluster() {
kind delete cluster --name $cluster_name
}
deploy_jupyterhub() {
helm repo add jupyterhub https://jupyterhub.github.io/helm-chart/
helm repo update
helm show values jupyterhub/jupyterhub | tee values.yaml
helm upgrade --cleanup-on-fail --install my-jupyter jupyterhub/jupyterhub --namespace jhub --create-namespace --values values.yaml
kubectl get pods -n jhub
}
set_env
install_exec "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/$arch/kubectl"
install_exec "https://kind.sigs.k8s.io/dl/latest/kind-linux-$arch" kind
install_helm
create_cluster
deploy_jupyterhub
#delete_cluster
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment