Install Rancher Using Terraform
The backup target makes a local copy of the k3s server directory. Do not commit this to git as it contains the keys to your Rancher kubernetes installation.
- terraform
- helm
- jq
- kubectl
- aws
- dns address for Rancher
cp terraform-setup/terraform.tfvars.template terraform-setup/terraform.tfvars
- Adjust the tfvars variables as desired
- Set your aws account id and key using the terraform variables
aws_access_key_id
aws_secret_access_key
- See
variables.tf
for other infrastructure configuration - Make sure you have a registered domain
- Use terraform variable
domain
to set it - Use terraform variable
rancher_url
to set the subdomain - fqdn is <rancher_url>.
- Use terraform variable
make rancher
Only do this once if you are keeping backups.make backup_rancher
Backup to thebackup
directorymake restore_rancher
Restore the rancher installation from thebackup
directory
infrastructure
- build the infrastructure needed to host k3s and Rancherk3s_sql_install
- use k3s backed by an RDS sql datastore- use parameter
RANCHER_NODE_COUNT=2
for a 2 node HA backend - HA capable
- use parameter
k3s_install
- use k3s with the default embedded sqlite datastore.- Single node only
- Not HA
- Local (workstation) backup and restore
rancher
- make the infrastructure and install the sqlite version of k3s and also Rancherbackup_rancher
- backup the currently installed sqlite k3s versionrestore_rancher
- restore the previously installed sqlite k3s version from a local copydestroy
- destroy the infrastructureinstall_kubeconfig
- run afterk3s_install
target. WARNING THIS WILL OVERWRITE YOUR LOCAL.kube/config
backup_kubeconfig
- backup your local.kube/config
before overwriting it withinstall_kubeconfig
Follow the quickstart steps to create, backup and restore rancher. Once the Rancher cluster is created it can be backed up or destroyed. If it is backed up, you can restore it using make restore_rancher
. The restore_rancher
target assumes that the backup exists and that the infrastructure has been destroy
ed.
Restoration may take some time even after the make process ends as kubernetes must right itself by downloading and installing resources that are backedup in the datastore. Follow the post restore steps that make prints out to complete the restore process.
- Set the admin password, rancher subdomain
make RANCHER_SUBDOMAIN="your-best-subdomain" ADMIN_SECRET="one-two-three" LETS_ENCRYPT_USER="[email protected]" rancher
- Backup to a named backup location
make BACKUP_LOCATION="backup/named_loc" backup_rancher
- Store your
ADMIN_SECRET
somewhere so that you can use it when you restore
- Restore from a named backup location
make RANCHER_SUBDOMAIN="your-best-subdomain" BACKUP_LOCATION="backup/named_loc" restore_rancher
RANCHER_SUBDOMAIN
is needed because the load balancer will get created in the infrastructure rebuild step