This folder shows an example of Terraform code that uses the consul-cluster module to deploy a Consul cluster in Azure. The cluster consists of two Virtual Machine Scale Sets (VMSSs): one with a small number of Consul server nodes, which are responsible for being part of the consensus quorum, and one with a larger number of client nodes, which would typically run alongside your apps:
You will need to create an Azure Image that has Consul installed, which you can do using the consul-image example). Note that to keep this example simple, both the server VMSS and client VMSS are running the exact same image. In real-world usage, you'd probably have multiple client VMSSs, and each of those VMSSs would run a different image that has the Consul agent installed alongside your apps.
For more info on how the Consul cluster works, check out the consul-cluster documentation.
To deploy a Consul Cluster:
git clone
this repo to your computer.- Build a Consul Image. See the consul-image example documentation for instructions. Make sure to note the ID of the image.
- Install Terraform.
- Create a
terraform.tfvars
file and fill in any other variables that don't have a default, including putting your IMAGE URL into theimage_uri
variable. - Run
terraform init
. - Run
terraform plan
. - If the plan looks good, run
terraform apply
. - Run the consul-examples-helper.sh script to
print out the IP addresses of the Consul servers and some example commands you can run to interact with the cluster:
../consul-examples-helper/consul-examples-helper.sh
.