github.com/yankunsam/loki/v2@v2.6.3-0.20220817130409-389df5235c27/production/ksonnet/enterprise-logs/scripts/k3d-cluster (about) 1 #!/usr/bin/env bash 2 set -euo pipefail 3 4 if [[ $# -ne 1 ]]; then 5 cat <<EOF 6 Create or delete a dev k3d cluster 7 8 Usage: 9 $0 create 10 $0 delete 11 EOF 12 fi 13 14 CLUSTER_NAME=enterprise-logs 15 16 case $1 in 17 create) 18 shift 19 # Make creation idempotent. 20 if k3d cluster list "${CLUSTER_NAME}" &>/dev/null; then 21 exit 0 22 fi 23 k3d cluster create "${CLUSTER_NAME}" 24 25 echo -n 'creating' 26 set +e 27 while ! k3d kubeconfig get "${CLUSTER_NAME}" &>/dev/null; do 28 sleep 1 29 echo -n '.' 30 done 31 set -e 32 echo 'done' 33 34 kubectl apply -f https://raw.githubusercontent.com/rancher/local-path-provisioner/master/deploy/local-path-storage.yaml 35 kubectl patch storageclass local-path -p '{"metadata":{"annotations":{"storageclass.kubernetes.io/is-default-class":"true"}}}' 36 37 kubectl config use-context k3d-"${CLUSTER_NAME}" 38 sleep 10 # Lazy sleep instead of checking for readiness of API server to handle all resources. 39 ;; 40 delete) 41 k3d cluster delete "${CLUSTER_NAME}" 42 shift 43 ;; 44 esac