This directory contains a Terraform configuration to deploy a bunch of Kubernetes clusters on various cloud providers, using their respective managed Kubernetes products.
To use it:
- Select the provider you wish to use.
Change the source attribute of the module "clusters" section.
Check the content of the modules directory to see available choices.
vim main.tf
- Initialize the provider.
terraform init
- Configure provider authentication.
-
Digital Ocean:
export DIGITALOCEAN_ACCESS_TOKEN=$(grep ^access-token ~/.config/doctl/config.yaml | cut -d: -f2 | tr -d " ") -
Google Cloud Platform: you will need to create a project named
prepare-tfand enable the relevant APIs for this project (sorry, if you're new to GCP, this sounds vague; but if you're familiar with it you know what to do; if you want to change the project name you can edit the Terraform configuration) -
Linode:
export LINODE_TOKEN=$(grep ^token ~/.config/linode-cli | cut -d= -f2 | tr -d " ") -
Oracle Cloud: if you have setup the OCI CLI (and have a
~/.oci/configconfig file), Terraform will use it by default -
Scaleway: run
scw init
- Decide how many clusters and how many nodes per clusters you want.
export TF_VAR_how_many_clusters=5
export TF_VAR_min_nodes_per_pool=2
# Optional (will enable autoscaler when available)
export TF_VAR_max_nodes_per_pool=4
# Optional (will only work on some providers)
export TF_VAR_enable_arm_pool=true
- Provision clusters.
terraform apply
- Perform second stage provisioning.
This will install a SSH server on the clusters.
cd stage2
terraform init
terraform apply
- Obtain cluster connection information.
The following command shows connection information, one cluster per line, ready to copy-paste in a shared document or spreadsheet.
terraform output -json | jq -r 'to_entries[].value.value'
- Destroy clusters.
cd ..
terraform destroy
- Clean up stage2.
rm stage2/terraform.tfstate*