Make things more configurable

This commit is contained in:
Jonas Juselius
2019-10-17 16:05:47 +02:00
parent 53e25ffb22
commit 81717fe223
12 changed files with 154 additions and 43 deletions

View File

@@ -1,6 +1,6 @@
#!/usr/bin/env bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.."
TOP="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )/.."
if [ $# != 1 ]; then
echo "usage: teardown.sh name"
@@ -8,24 +8,30 @@ if [ $# != 1 ]; then
fi
d=$1
f=$DIR/clusters/$d/.$d.$$
f=$TOP/clusters/$d/.$d.$$
# nixops ssh -d $d ${d}0-0 kubectl delete --all pods
# nixops ssh -d $d ${d}0-0 kubectl --namespace kube-system delete --all pods
# sleep 60
teardown () {
sed -s 's/cluster.\(apiserver\|worker\)/cluster.host/' $DIR/clusters/$d/default.nix > $f
sed -s 's/cluster.\(apiserver\|worker\)/cluster.host/' $TOP/clusters/$d/default.nix > $f
nixops modify -d $d $f
nixops deploy -d $d
# nixops reboot -d $d
# nixops ssh-for-each -d $d "rm -rf /var/run/kubernetes /var/lib/kubernetes /var/lib/etcd /var/lib/kubelet /var/lib/cfssl"
nixops reboot -d $d
nixops ssh-for-each -d $d "rm -rf /var/run/kubernetes /var/lib/kubernetes /var/lib/etcd /var/lib/kubelet /var/lib/cfssl"
rm $f
}
cat << EOF
echo "Are you sure you want to tear down $d? (yes/no)"
************************************************************************
*** ***
*** WARNING: This will irrevokably destroy the running cluster! ***
*** ***
************************************************************************
EOF
echo "Are you sure you want to tear down $d? (YES/no)"
read a
case $a in
yes) teardown ;;
*) : ;;
YES) teardown ;;
*) echo "Bailing out." ;;
esac