diff --git a/README.md b/README.md index 265ecbae..0cea52dd 100644 --- a/README.md +++ b/README.md @@ -70,10 +70,10 @@ Follow those simple steps, and your world's cheapest Kubernetes cluster will be First and foremost, you need to have a Hetzner Cloud account. You can sign up for free [here](https://hetzner.com/cloud/). -Then you'll need to have [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli), [packer](https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli#installing-packer) (for the initial snapshot creation only, no longer needed once that's done), [kubectl](https://kubernetes.io/docs/tasks/tools/) cli and [hcloud](https://github.com/hetznercloud/cli) the Hetzner cli for convenience. The easiest way is to use the [homebrew](https://brew.sh/) package manager to install them (available on Linux, Mac, and Windows Linux Subsystem). +Then you'll need to have [terraform](https://learn.hashicorp.com/tutorials/terraform/install-cli) or [tofu](https://opentofu.org/docs/intro/install/), [packer](https://developer.hashicorp.com/packer/tutorials/docker-get-started/get-started-install-cli#installing-packer) (for the initial snapshot creation only, no longer needed once that's done), [kubectl](https://kubernetes.io/docs/tasks/tools/) cli and [hcloud](https://github.com/hetznercloud/cli) the Hetzner cli for convenience. The easiest way is to use the [homebrew](https://brew.sh/) package manager to install them (available on Linux, Mac, and Windows Linux Subsystem). ```sh -brew install terraform +brew install terraform # or brew install opentofu brew install packer brew install kubectl brew install hcloud diff --git a/scripts/cleanup.sh b/scripts/cleanup.sh index 70414174..85b0dc12 100755 --- a/scripts/cleanup.sh +++ b/scripts/cleanup.sh @@ -10,6 +10,16 @@ command -v hcloud >/dev/null 2>&1 || { echo "hcloud (Hetzner CLI) is not install echo "You can do so by running 'hcloud context create ' and inputting your HCLOUD_TOKEN." echo " " +if command -v tofu >/dev/null 2>&1 ; then + terraform_command=tofu +elif command -v terraform >/dev/null 2>&1 ; then + terraform_command=terraform +else + echo "terraform or tofu is not installed. Install it with 'brew install terraform' or 'brew install opentofu'." + exit 1 +fi + + # Try to guess the cluster name GUESSED_CLUSTER_NAME=$(grep -oP 'cluster_name\s*=\s*"\K([^"]+)' kube.tf) @@ -52,7 +62,7 @@ fi HCLOUD_SELECTOR=(--selector='provisioner=terraform' --selector="cluster=$CLUSTER_NAME") HCLOUD_OUTPUT_OPTIONS=(-o noheader -o 'columns=id') -NODEPOOLS=( $(terraform state list | grep -oP 'module.kube-hetzner.data.hcloud_servers.autoscaled_nodes\["\K([^"]+)') ) +NODEPOOLS=( $(${terraform_command} state list | grep -oP 'module.kube-hetzner.data.hcloud_servers.autoscaled_nodes\["\K([^"]+)') ) VOLUMES=() while IFS='' read -r line; do VOLUMES+=("$line"); done < <(hcloud volume list "${HCLOUD_SELECTOR[@]}" "${HCLOUD_OUTPUT_OPTIONS[@]}") diff --git a/scripts/create.sh b/scripts/create.sh index ca0775b7..b29cb847 100755 --- a/scripts/create.sh +++ b/scripts/create.sh @@ -5,10 +5,16 @@ command -v ssh >/dev/null 2>&1 || { echo "openssh is not installed. Install it with 'brew install openssh'." exit 1 } -command -v terraform >/dev/null 2>&1 || { - echo "terraform is not installed. Install it with 'brew install terraform'." + +if command -v tofu >/dev/null 2>&1 ; then + terraform_command=tofu +elif command -v terraform >/dev/null 2>&1 ; then + terraform_command=terraform +else + echo "terraform or tofu is not installed. Install it with 'brew install terraform' or 'brew install opentofu'." exit 1 -} +fi + command -v packer >/dev/null 2>&1 || { echo "packer is not installed. Install it with 'brew install packer'." exit 1 @@ -72,4 +78,4 @@ fi echo " " echo "Remember, don't skip the hcloud cli, to activate it run 'hcloud context create '. It is ideal to quickly debug and allows targeted cleanup when needed!" echo " " -echo "Before running 'terraform apply', go through the kube.tf file and fill it with your desired values." +echo "Before running '${terraform_command} apply', go through the kube.tf file and fill it with your desired values."