Skip to content
This repository has been archived by the owner on Jan 25, 2023. It is now read-only.

Latest commit

 

History

History
93 lines (64 loc) · 6.35 KB

README.md

File metadata and controls

93 lines (64 loc) · 6.35 KB

DISCLAIMER: This is no longer supported.

Moving forward in the future this repository will be no longer supported and eventually lead to deprecation. Please use our latest versions of our products moving forward or alternatively you may fork the repository to continue use and development for your personal/business use.


Terraform Version

Consul for Google Cloud Platform (GCP)

This repo contains a Terraform Module for how to deploy a Consul cluster on GCP using Terraform. Consul is a distributed, highly-available tool that you can use for service discovery and key/value storage. A Consul cluster typically includes a small number of server nodes, which are responsible for being part of the consensus quorum, and a larger number of client nodes, which you typically run alongside your apps:

Consul architecture

How to use this Module

Each Module has the following folder structure:

  • modules: This folder contains the reusable code for this Module, broken down into one or more submodules.
  • examples: This folder contains examples of how to use the submodules.
  • test: Automated tests for the submodules and examples.

To deploy Consul servers using this Module:

  1. Create a Consul Image using a Packer template that references the install-consul module. Here is an example Packer template. Note that Google Cloud does not support custom public Images so you must build this Packer template on your own to proceed.

  2. Deploy that Image across a Compute Instance Group using the Terraform consul-cluster module and execute the run-consul script with the --server flag during boot on each Instance in the Compute Instance Group to form the Consul cluster. Here is an example Terraform configuration to provision a Consul cluster.

To deploy Consul clients using this Module:

  1. Use the install-consul module to install Consul alongside your application code.
  2. Before booting your app, execute the run-consul script with --client flag.
  3. Your app can now usr the local Consul agent for service discovery and key/value storage.
  4. Optionally, you can use the install-dnsmasq module to configure Consul as the DNS for a specific domain (e.g. .consul) so that URLs such as foo.service.consul resolve automatically to the IP address(es) for a service foo registered in Consul (all other domain names will be continue to resolve using the default resolver on the OS).

What's a Terraform Module?

A Terraform Module refers to a self-contained packages of Terraform configurations that are managed as a group. This repo is a Terraform Module and contains many "submodules" which can be composed together to create useful infrastructure patterns.

Who created this Module?

These modules were created by Gruntwork, in partnership with HashiCorp, in 2017 and maintained through 2021. They were deprecated in 2022, see the top of the README for details.

Code included in this Terraform Module:

  • install-consul: This module installs Consul using a Packer template to create a Consul Custom Image.

  • consul-cluster: The module includes Terraform code to deploy a Consul Image across a Managed Compute Instance Group.

  • run-consul: This module includes the scripts to configure and run Consul. It is used by the above Packer module at build-time to set configurations, and by the Terraform module at runtime with the Instance's Startup Script to create the cluster.

  • install-dnsmasq module: Install Dnsmasq and configure it to forward requests for a specific domain to Consul. This allows you to use Consul as a DNS server for URLs such as foo.service.consul.

How is this Terraform Module versioned?

This Terraform Module follows the principles of Semantic Versioning. You can find each new release, along with the changelog, in the Releases Page.

During initial development, the major version will be 0 (e.g., 0.x.y), which indicates the code does not yet have a stable API. Once we hit 1.0.0, we will make every effort to maintain a backwards compatible API and use the MAJOR, MINOR, and PATCH versions on each release to indicate any incompatibilities.

License

This code is released under the Apache 2.0 License. Please see LICENSE and NOTICE for more details.

Copyright © 2017 Gruntwork, Inc.