Skip to content

Latest commit

 

History

History

mgmt

Terraform for Provisioning a TKG Management cluster in AWS

Uses Terraform to install Tanzu Kubernetes Grid management cluster in AWS.

See Deploy Management Clusters to Amazon EC2 with the CLI

Assumes:

Copy sample configuration

cp terraform.tfvars.sample terraform.tfvars

Edit terraform.tfvars

Amend the values for

  • environment
  • aws_secret_key_id
  • aws_secret_access_key
  • aws_ssh_key_name
  • path_to_tkg_config_yaml

There are other variable values you can adjust. Peek at main.tf to see what's available.

Provision

./create-mgmt-cluster.sh

If you chose the dev plan the installation normally completes in less than 10 minutes.

Destroy

./destroy-mgmt-cluster.sh

Troubleshooting

Sleuthing cluster-api error indicators in bootstrap cluster

kubectl describe cluster-api -A --kubeconfig ~/.kube-tkg/tmp/{config}

Look for occurrences of "Error" or "Exception"

Deleting the management cluster

With tkg 1.2, attempting to delete the management cluster fails.

Here's the work-around...

  • Download and install the 0.5.5 release of clusterawsadm. (Pick a binary suitable for the operating system that hosts your development or continuous integration environment.).
  • Export the missing environment variable with export AWS_B64ENCODED_CREDENTIALS=$(clusterawsadm alpha bootstrap encode-aws-credentials)
  • Re-attempt to delete the management cluster with tkg delete management-cluster {tkg_mgmt_cluster_name} --config {path_to_config_yaml_file}

Removing the bootstrap cluster

The bootstrap cluster runs with kind.

If you have kind installed you can run

kind get clusters

then use the name of the cluster to delete it

kind delete clusters {name}

Starting from a clean slate

If you want to get back to clean initial state execute the following sequence of commands.

rm -Rf ~/.tkg                                       ## Destroys all TKG configuration 
rm -Rf ~/.kube                                      ## Destroys all Kubernetes cluster context
rm -Rf ~/.kube-tkg                                  ## Destroys all TKG bootstrap context
docker container prune                              ## Prunes all unused containers, reclaiming disk space
docker volume prune                                 ## Prunes all unused volumes, reclaiming disk space
docker rmi registry.tkg.vmware.run/kind/node:{tag}  ## Removes the container image used to provision TKG clusters

More tips

Consult the VMWare Tanzu Kubernetes Grid troubleshooting documentation