This Terraform setup will:
- Provision Digital Ocean droplets and install the Docker daemon on these
- Create a cluster.yml configuration file containing those droplets to enable provisioning a Kubernetes clusters with Rancher Kubernetes Engine (RKE)
- Create an ssh_config file in the terraform module directory for connecting to the droplets
All available options/variables are described in terraform.tfvars.example.
- Clone this repository
- Move the file
terraform.tfvars.example
toterraform.tfvars
and edit (see inline explanation) - Run
terraform init
- Run
terraform apply
- Once terraform provisioning has completed you can provision a Kubernetes cluster with RKE
rke up --config cluster.yml
. The RKE binary is required and can be installed per docs - When
terraform destroy
is performed, the Kubernetes CLI configuration filekube_config_cluster.yml
and RKE state filecluster.rkestate
auto-generated by RKE will be deleted from the directory, if present, alongside thecluster.yml
created by terraform.
- Run
./rancher-install.sh -H <rancher hostname> -v <version string>
where is the URL for the rancher server and is a version string of the format 2.2.8 for example.
- Run
./rancher-install.sh -H <rancher hostname> -v <version string> -t letsEncrypt
where is the URL for the rancher server and is a version string of the format 2.2.8 for example.
- Run
./certs.sh <rancher hostname>
where is the URL for the rancher server for which to generate certificates. - Run
./rancher-install.sh -H <rancher hostname> -v <version string> -t secret
where is the URL for the rancher server and is a version string of the format 2.2.8 for example.
You can use the use the auto-generated ssh_config file to connect to the droplets by droplet name, e.g. ssh <prefix>-rke-0-all
or ssh <prefix>-rke-1-etcd
etc. To do so, you have two options:
-
Add an
Include
directive at the top of the SSH config file in your home directory (~/.ssh/config
) to include the ssh_config file at the location you have checked out the this repository, e.g.Include ~/git/tf-do-rke/ssh_config
. -
Specify the ssh_config file when invoking
ssh
via the-F
option, e.g.ssh -F ~/git/tf-do-rke/ssh_config <host>
.