The contents of this repository are currently being rewritten into discreet modules. Expect some breakage while this is happening! The original work can be found here: https://github.com/drpebcak/rancher-as-code/tree/infra-as-code-demo
This repository contains:
An example on how to set up rancher server in an HA configuration using terraform.This is now a separate module that can be found at https://github.com/drpebcak/terraform-rancher-server- How to provision a cluster for workloads and attach that to rancher using terraform
- How to manage a provisioned cluster using rancher and terraform
- How to deploy applications into the cluster using terraform
This example uses the terraform RKE provider - https://github.com/yamamoto-febc/terraform-provider-rke. To use this, you need to follow the installation instructions. Please note that it relies on a feature which has been merged but not released, so currently the best way to use this is to build terraform-provider-rke
on your system rather than download from a release.
- Go into the
rancher-server
directory
- This directory contains terraform that uses RKE to set up a kubernetes cluster, configures helm, installs cert-manager, and then installs rancher.
- Run terraform
terraform init
terraform apply
- You will probably want to modify some of the locals for your environment
- Go into the
user-cluster
directory
- This directory contains terraform that uses the rancher2 provider to create a custom cluster that is managed by rancher.
- Run terraform
terraform init
terraform apply
- You will probably want to modify some of the locals for your environment
- Go to the
install-app
directory
- This directory contains terraform that uses the rancher2 provider to add a custom catalog and install a helm chart.
- Run terraform
terraform init
terraform apply
If you don't work at rancher, you will probably need to modify some of this configuration. The aws
provider assumes you want to use a specific profile
for access to AWS. Feel free to modify this in rancher-server
and user-cluster
. We also sort of assume that you want a domain name for rancher-server
based on ${local.name}.${local.domain}
- you should probably change those as well. Finally, we are assuming that you use Route53 for your DNS. In rancher-server/infra.tf
we make a DNS record for your rancher server. If you do not use Route53, you should change this to reference whatever DNS provider you would like to use instead.