mirror of
https://github.com/jpetazzo/container.training.git
synced 2026-02-14 17:49:59 +00:00
1.7 KiB
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:
- 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 " "
)
- 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
- 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 stage/terraform.tfstate*