Files
container.training/prepare-tf/README.md
2021-12-14 15:46:00 +01:00

1.7 KiB

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:

  1. 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
  1. Initialize the provider.
terraform init
  1. Configure provider authentication.
  • Digital Ocean:
    export DIGITALOCEAN_ACCESS_TOKEN=$(grep ^access-token ~/.config/doctl/config.yaml | cut -d: -f2 | tr -d " "
    

)

- Linode:
```bash
export LINODE_TOKEN=$(grep ^token ~/.config/linode-cli | cut -d= -f2 | tr -d " ")
  • Oracle Cloud: it should use ~/.oci/config
  • Scaleway: run scw init
  1. 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
  1. Provision clusters.
terraform apply
  1. Perform second stage provisioning.

This will install a SSH server on the clusters.

cd stage2
terraform init
terraform apply
  1. 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'
  1. Destroy clusters.
cd ..
terraform destroy
  1. Clean up stage2.
rm stage/terraform.tfstate*