Announcing a New Terraform Module for GCE | SUSE Communities

Announcing a New Terraform Module for GCE

Share

I’m pleased to announce that Rancher has released a new Terraform
module
for deploying
Rancher on Google Compute Engine (GCE). This complements our existing
module for Amazon Web Services (AWS). Terraform is an excellent tool for
managing infrastructure as code, and many of our users already make use
of it elsewhere in their environments. Using this module along with
either GCE or AWS to orchestrate Rancher gives you the ability to
define the entirety of the stack—from the application layer being
managed by Docker Compose or Kubernetes resource YML in Rancher all the
way down to the servers and networks in the Terraform plan. This ability
to create an entire production stack in one click is very powerful. For
instance, if you want to replicate production to simulate a change, just
spin up a clone in another account. Once you’re done with your tests,
you can throw that environment away to save on costs as well as to avoid
keeping state around that is prone to getting stale, or out of date with
production. To get started, we’ve provide a sample terraform plan that
implements the module. You’ll need to provide a few parameters to the
plan, which you can do interactively when you run it or by adding a file
called “terraform.tfvars” to the same directory as the example.

First you’ll want to run the database plan to create the GCE CloudSQL
instance. From the above directory:

cd database

terraform apply

Once this is complete, then you can run the management server plan. This
plan will reference the previous database plan to get the connection
details of the database.

cd ../management-cluster

terraform apply

This should create the GCE instances running RancherOS and Rancher
server. Head over to the GCE management console to get the public IP
address of your instance. You can connect to it on port 8080. Remember
the above is just an example plan that implements the module. You can
also reference the module in an existing plan like so:

module "gce_compute" {

   source = "../../../modules/gce/compute"  // replace with relative path if you checked out module to different location

   name = "my-rancher-cluster"

   gce_project = "myproject"

   ... // remaining parameters

}

You can read more about how to use Terraform modules here. Our terraform
modules for both AWS and GCE are located on Github. Happy Terraforming!