Skip to content

Latest commit

 

History

History
98 lines (78 loc) · 8.04 KB

README.md

File metadata and controls

98 lines (78 loc) · 8.04 KB

Terraform Module for RKE2 and Rancher v2.6.0 on vSphere

This repository aims at providing a reference configuration / module to use in order to:

  • Create a set of VMs on vSphere using CentOS 8.4
  • Deploy 2 RKE2 Clusters, one with 3 nodes for Rancher and one with a variable amount of nodes as a downstream (application) cluster
  • Have Rancher automatically installed with a given certificate on the 3-node cluster
  • Have the other cluster automatically be imported into the Rancher installation.

Principle

The principle to achieve the above uses Terraform Modules:

  • A module for the infrastructure (creating VMs in vSphere)
  • A module for the installation of RKE2 (with or without Rancher)
  • A module for installing Apps through the Rancher Market Place.
  • A module for importing a cluster into Rancher

Naturally, it is possible to modify the configuration to adapt it to you own needs. Example: if you don't need the provisioning of VMs in vSphere, you can use remove the call to that module in the main.tf and modify the other module calls (rke2-upstream-provision and rke2-downstream-provision) to use some other source for the IP addresses.

Usage

Pre-requisites

Variables

A number of values necessary to the deployment of a Rancher platform were parametrized, making the module quite flexible. Some variables do not have a default value, it is necessary to provide these values for the configuration to apply. You can run terraform apply and answer the prompts with the necessary values, but this would be cumbursome. A better solution is to make use of a tfvars kind of file, which is a simple file with key,value pairs providing Terraform with all the necessary input it needs.

An sample terraform.tfvars is provided in the configuration, you can adapt it for your own environment.

RKE2 Binaries

The module tf-module-rke2-provision deploys RKE2 in an Air Gapped environment using the procedure described here using the tarvall method. This procedure needs pre-downloaded tarball distribution of RKE2 including the RKE2 binary, all the system container images as well as a SHA256 checksum file, all of which can be found on the Github Releases page for RKE2. These files should be copied into the folder tf-module-rke2-provision/rke2. Please also make sure to have a install.sh file in the same folder, coming from the current RKE2 installation script.

Module description

Requirements

Name Version
kubectl 1.13.0
rancher2 1.20.0

Providers

Name Version
null 3.1.0
rancher2.bootstrap 1.20.0

Modules

Name Source Version
rke2-downstream-import-cluster ./tf-module-downstream-deploy n/a
rke2-downstream-provision ./tf-module-rke2-provision n/a
rke2-upstream-provision ./tf-module-rke2-provision n/a
vsphere-infra-downstream ./tf-module-vsphere-infra n/a
vsphere-infra-rancher ./tf-module-vsphere-infra n/a

Resources

Name Type
null_resource.rancher_availability_check resource
rancher2_bootstrap.admin resource

Inputs

Name Description Type Default Required
app_cluster_description Description of the Downstream Cluster to be created string n/a yes
app_cluster_name Name of the Downstream Cluster to be created string n/a yes
downstream_cp_vm_count Number of Control Plane VMs for the downstream Cluster number n/a yes
downstream_vm_name_prefix Name prefix for the Downstream VMs string n/a yes
downstream_wk_vm_count Number of Worker VMs for the downstream Cluster number n/a yes
public_key_path path of public key to push to the VMs any n/a yes
rancher_bootstrap_password Desired password for Rancher string n/a yes
rancher_hostname Desired hostname for the Rancher App any n/a yes
rancher_vm_count Number of VMs to spin up for RKE number 3 no
rancher_vm_name_prefix Prefix for the VM name in vSphere string "rancher-ha" no
rke2_token Desired RKE2 token any n/a yes
ssh_password SSH Password to connect to VM with any n/a yes
ssh_user SSH Username to connect to VM with any n/a yes
vcenter_host n/a string "" no
vcenter_password n/a string "" no
vcenter_username n/a string "" no
vm_cpus Number of CPUs to give to VM number 2 no
vm_disk_size Size in GB of the main VM's Disk number 20 no
vm_mem Memory size in MB for VM number 8192 no
vm_template n/a string "" no
vsphere_dc vSphere Datacenter to use to create VMs any n/a yes
vsphere_ds vSphere Datastore to use to create VMs any n/a yes
vsphere_guest_id Type of OS for Guest string "rhel7_64Guest" no
vsphere_net vSphere Network to attribute the VMs to any n/a yes
vsphere_rp vSphere Resource Pool to attribute the VMs to any n/a yes

Outputs

Name Description
downstream_import_manifest n/a
downstream_kubeconfig n/a
upstream_kubeconfig n/a