Deploy Rancher on AWS
Go to file
github-actions[bot] 5a68f24262
chore(main): release 1.0.3 (#75)
Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
2025-03-25 15:56:18 -05:00
.github fix: allow for plugin cache (#71) 2025-03-25 11:57:55 -05:00
examples fix: update the prep scripts and module versions (#67) 2025-03-24 13:30:26 -05:00
modules fix: plugin cache directory (#74) 2025-03-25 15:49:33 -05:00
test fix: allow for plugin cache (#71) 2025-03-25 11:57:55 -05:00
.aliases feat: implement high availability cluster (#2) 2024-06-25 13:48:59 -06:00
.envrc fix: enable automatic testing and refactor tests (#51) 2025-01-13 07:57:45 -06:00
.functions feat: implement high availability cluster (#2) 2024-06-25 13:48:59 -06:00
.gitignore feat: enable node configuration (#21) 2024-10-01 16:05:27 -05:00
.rcs feat: implement high availability cluster (#2) 2024-06-25 13:48:59 -06:00
.variables feat: implement high availability cluster (#2) 2024-06-25 13:48:59 -06:00
CHANGELOG.md chore(main): release 1.0.3 (#75) 2025-03-25 15:56:18 -05:00
LICENSE Initial commit 2023-07-10 13:23:09 -05:00
README.md feat!: release version one (#68) 2025-03-24 15:12:46 -05:00
flake.lock fix: allow for plugin cache (#71) 2025-03-25 11:57:55 -05:00
flake.nix fix: allow for plugin cache (#71) 2025-03-25 11:57:55 -05:00
main.tf fix: enable ambient credentials (#59) 2025-01-28 16:26:59 -06:00
outputs.tf fix: example with cert manager configured (#30) 2024-10-31 01:13:50 -05:00
run_tests.sh fix: allow for plugin cache (#71) 2025-03-25 11:57:55 -05:00
terraform.md feat: implement high availability cluster (#2) 2024-06-25 13:48:59 -06:00
variables.tf fix: enable ambient credentials (#59) 2025-01-28 16:26:59 -06:00
versions.tf fix: allow module plugin cache (#69) 2025-03-24 17:59:45 -05:00

README.md

Terraform Rancher Module

This module deploys infrastructure in AWS, installs rke2, then uses the rancher2 provider to install and configure rancher. This module combines other modules that we provide to give holistic control of the lifecycle of the rancher cluster.

Requirements

Provider Setup

Only two of the providers require setup:

We recommend setting the following environment variables for quick personal use:

GITHUB_TOKEN
AWS_REGION
AWS_SECRET_ACCESS_KEY
AWS_ACCESS_KEY_ID
ZONE

Tools

These tools will need to be installed on the machine running Terraform:

  • curl
  • jq
  • kubectl
  • terraform

Local Filesystem Write Access

You will need write access to the filesystem on the server running Terraform. If downloading the files from GitHub, then you will need about 2GB storage space available in the 'local_file_path' location (defaults to ./rke2).

Examples

We have a few example implementations to get you started, these examples are tested in our CI before release. When you use them, update the source and version to use the Terraform registry.

Local State

The specific use case for the example modules is temporary infrastructure for testing purposes. With that in mind, it is not expected that we manage the resources as a team, therefore the state files are all stored locally. If you would like to store the state files remotely, add a terraform backend file (*.name.tfbackend) to your root module. https://www.terraform.io/language/settings/backends/configuration#file

Some of the submodules use internal local state files, but generally those are considered not necessary for the overall project. If you are using remote state files and would like to be able to pass a backend file to the sub modules please open an issue.

Development and Testing

Paradigms and Expectations

Please make sure to read terraform.md to understand the paradigms and expectations that this module has for development.

Environment

It is important to us that all collaborators have the ability to develop in similar environments, so we use tools which enable this as much as possible. These tools are not necessary, but they can make it much simpler to collaborate.

  • I use nix that I have installed using their recommended script
  • I source the .envrc to get started
    • it sets up all needed dependencies and gives me a set of tools that I can use to test and write the Terraform module.
  • I use the run_tests.sh script in this directory to run the tests, along with the alias 'tt'
    • eg. tt -r will rerun failed tests (once only)
    • eg. tt -f=BasicTest will run only the BasicTest
  • I store my credentials in local files and generate a symlink to them
    • eg. ~/.config/github/default/rc
    • this will be automatically sourced when you enter the nix environment (and unloaded when you leave)
    • see the .envrc and .rcs file for the implementation

Automated Tests

Our continuous integration tests using the GitHub ubuntu-latest runner, we then rely on Nix to deploy the additional dependencies.

It also has special integrations with AWS to allow secure authentication, see https://docs.github.com/en/actions/deployment/security-hardening-your-deployments/configuring-openid-connect-in-amazon-web-services for more information.

With this tool it is possible to retrieve the aws access key and aws secret key to the temporarily defined access to the AWS account. We send these to Rancher when building our tests, this allows us to temporarily and securely setup certmanger and Rancher provisioning.