install-scripts/proxmox-k8s/k8s-proxmox-script-prompt.md

2.4 KiB

Please generate me a bash script to deploy a Kubernetes cluster across multiple VM's. The script should complete every step for the user. Include colour coded echo statements to make it easy to use. It needs to include the following steps:

  1. Ask the user to input the number of nodes that are going to be part of the K8S cluster.

  2. Ask the user to input the IP's and SSH credentials for each node. The script needs to temporarily store these credentials in the linux tmp directory to use for the rest of this process. Following the users input, the script should then list all the previously inputed IP addresses and ask the user to confirm they are correct. If the user declares they are not, the script should offer them the option to go back and edit them before proceeding with the next step.

  3. It should then ask the user which node (by number or IP) they would like to define as the master node/control plane. All other nodes should be assumed to be worker nodes.

  4. It should then proceed to use the previously defined SSH credentials to log in to each node sequentially and add the K8S repository and relevant keys.

  5. Following this, it should log in to each node sequentially and run apt update and apt upgrade, followed by the rebooting of each node. Following the successful execution of this task (and while the nodes are rebooting), the script should include a time delay of 5 minutes while displaying a countdown in seconds to allow each node to reboot.

  6. It should then proceed to use the credentials of the corresponding node to install K8S on the master node initially. The install must add the official K8S repository to the system sources list and then run apt update before proceeding with the installation.

  7. Following the successful completion of the K8S installation, the script must then offer the user the following options in order to complete the K8S configuration. The script must parse the users choices to the relveant configuration files and then restart all K8S services.

    1. Port number: The script must offer the user the option to define a custom port. If no choice is made the script should resort to the default.

    2. Listening IP or domain: The script must offer the user the option to input the IP address or FQDN that K8S will listen on.

  8. After completing the installation of Kubernetes on the master node, the script must then proceed to add the official K8S repo to all the master nodes and then install K8S on each machine.