Deploy Kubernetes clusters using Rancher and Terraform on bare metal servers
rancher_api_url
should be in the format https://<your-rancher-server>/v3
.node_count
variable if you need a different number of nodes.Download the example files
Initialize Terraform
bash terraform init
Update variables
variables.tf
file with your details:LATITUDESH_AUTH_TOKEN
: Don’t hardcode this. You will be asked for it when planning and applying your plan.project_id
: The ID of the project you want to deploy to. Find this from the home page in the console by clicking on the three dots above the project followed by Copy ID.plan
: The plan slug. Simply replace the plan name with hyphens instead of dots. For example, for the m4.metal.medium, use m4-metal-medium
region
: The slug of the location you want to deploy to. E.g., for Dallas use DAL
. Find all with the api.latitude.sh/locations endpoint.ssh_key_id
: The ID of the SSH key you want to use for the nodes. Find this in the console under Project settings > SSH keysprivate_key_path
: This script will access your servers during setup. Add the local path in your computer where the private key of the SSH Key inserted above.rancher_api_url
: The rancher_api_url
should be in the format https://<your-rancher-server>/v3
.RANCHER_ACCESS_KEY
: The access key is available in your control plane. Find more details on the Rancher docs. Create one from the Rancher UI by going to User > Account & API Keys.RANCHER_SECRET_KEY
: The token’s password. Find more details on Rancher Doc in the API Keys.server_count
: Number of nodes to provision and add to the cluster.Plan your Terraform execution
bash terraform plan -var-file="secret.tfvars"
Apply the changes
yes
when prompted.