cloud-demo/scripts/cleanup-manual-vm.sh

16 lines
658 B
Bash
Executable file

#!/usr/bin/env bash
# Tears down stage 2's throwaway k3s-manual VM (docs/02-k3s.md).
# See docs/04-tofu.md, "Tearing down the manual VM" for what each step does
# and why nothing else needs cleaning up.
set -euo pipefail
read -p "This will destroy the k3s-manual VM and its disks. Continue? [y/N] " confirm
[[ "$confirm" =~ ^[Yy]$ ]] || exit 0
virsh -c qemu:///system destroy k3s-manual 2>/dev/null || true
virsh -c qemu:///system undefine k3s-manual --remove-all-storage 2>/dev/null || true
virsh -c qemu:///system vol-delete --pool default k3s-manual-base.qcow2 2>/dev/null || true
rm -f ~/.kube/config-manual
rm -rf ~/vms
echo "k3s-manual cleaned up."