Deploy HCP Consul Dedicated
HashiCorp Cloud Platform (HCP) Consul lets you start using Consul for service discovery and service mesh with less setup time. It does this by providing fully managed Consul servers. Consul offers service discovery, service mesh, traffic management, and automated updates to network infrastructure device.
In this tutorial, you will deploy an HCP Consul Dedicated server cluster, your choice of Kubernetes or virtual machine Consul clients, and a demo application. Then, you will explore how the demo application leverages Consul service mesh and interact with Consul using the CLI and UI.
In the following tutorials, you will interact with intentions to learn how to control service access within the service mesh, and route traffic using service resolvers and service splitters.
Prerequisites
The tutorial assumes that you are familiar with the standard Consul workflow. If you're new to Consul itself, refer first to the Getting Started tutorials for Kubernetes or virtual machines (VMs).
While you can deploy a HCP Consul Dedicated server and connect the Consul clients in your cloud environments manually, this tutorial uses a Terraform quickstart configuration to significantly reduce deployment time.
You do not need to be an expert with Terraform to complete this tutorial or use this quickstart template.
For this tutorial, you will need:
- The Terraform v1.0.0+ installed
- Git installed
- An HCP account configured for use with Terraform
- An AWS account with AWS Credentials configured for use with Terraform
- The
awscli v2.7.31+
configured.
Tip
This Get Started with HCP collection currently only supports HCP Consul on AWS. Visit the Deploy HCP Consul Dedicated with VM using Terraform and Deploy HCP Consul Dedicated with AKS using Terraform to learn how to deploy HCP Consul Dedicated on Azure.
Retrieve end-to-end Terraform configuration
The HCP Portal has a quickstart template that deploys an end-to-end development environment so you can quickly observe HCP Consul Dedicated in action. This Terraform configuration:
- Creates a new HashiCorp virtual network (HVN) and single-node Consul development server
- [Optional] Connects the HVN with your AWS VPC. This is only required if you select the EC2 option. For EKS, Consul Dataplane connects to the HCP Consul Dedicated cluster on the public IP address so you do not need to peer the networks.
- Provisions an AWS EKS cluster or virtual machine (EC2) instance and installs a Consul client
- Deploys HashiCups, a demo application that uses Consul service mesh
Note
These modules are only intended for demonstration purposes. While the Consul clients will be deployed secure-by-default, the limited configuration options presented by the module are to aid a user in quickly getting started.
Click below to learn more about these steps.
This architectural diagram shows a standard HCP Consul Dedicated cluster peered to a virtual network (for example, an AWS VPC or an Azure VNet). The virtual network has Consul clients and services on the service mesh.
To retrieve the end-to-end Terraform configuration, visit the HCP Portal, select Consul, then click Create Cluster.
Select AWS, then select the Terraform Automation creation method.
Select your runtime and scroll to the bottom to find the generated Terraform code.
Click on Copy code to copy it to your clipboard and save it in a file named main.tf
.
Note
Content should resemble the example below. This example is not guaranteed to be up to date. Always refer to the Terraform configuration presented in the HCP Portal.
Locals
The HCP Consul Dedicated UI will guide you into selecting the correct values for the local
variables. You can edit the cluster_id
and hvn_id
but make sure it does not
conflict with other deployments you have in your organization.
vpc_region
- This is the region where you deployed your VPC.hvn_region
- The HashiCorp Virtual Network (HVN) region.cluster_id
- The HCP Consul Dedicated cluster ID. Use a unique name to identify your HCP Consul Dedicated cluster. HCP will pre-populate this variable with a name and use the following the naming patternconsul-quickstart-<unique-ID>
.hvn_id
- The HCP HVN ID. Use a unique name to identify your HVN. HCP will pre-populate this variable with a name and use the following the naming patternconsul-quickstart-<unique-ID>-hvn
.
In addition, based on the run-time, you will have the following additional local variables.
install_demo_app
- This deploys the HashiCups demo application that will let you quickly explore how services interact with Consul service mesh.install_eks_cluster
- This deploys an EKS cluster and configures to connect to your HCP Consul Dedicated cluster.
Deploy end-to-end development environment
Now that you have the Terraform configuration, you are now ready to deploy your infrastructure. Before you continue, verify that you have populated your AWS and HCP credentials as mentioned in the prerequisites.
Initialize the configuration to install the necessary providers and modules.
Next, deploy the end-to-end development environment. Confirm the apply with a
yes
.
Once you confirm, it will take a few minutes for Terraform to set up your end-to-end development environment.
Verify created resources
Once Terraform completes, you can verify the resources using the Consul UI or CLI.
Verify with Consul UI
Retrieve your HCP Consul Dedicated dashboard URL and open it in your browser.
Next, retrieve your Consul root token. You will use this token to authenticate your Consul dashboard.
In your HCP Consul Dedicated dashboard, sign in with the root token you just retrieved.
You should find a list of services that include consul
, ingress-gateway
,
and your HashiCups services.
Verify with Consul CLI
In order to use the CLI, you must set environment variables that store your ACL token and HCP Consul Dedicated cluster address.
First, set your CONSUL_HTTP_ADDR
environment variable.
Then, set your CONSUL_HTTP_TOKEN
environment variable.
Retrieve a list of members in your datacenter to verify your Consul CLI is set up properly.
Verify demo application
The end-to-end development environment deploys HashiCups. Visit the hashicups
URL to verify that Terraform deployed HashiCups successfully, and its services
can communicate with each other.
Tip
View the Kubernetes manifest files that defines the HashiCups application to learn more about how the HashiCups services interact with each other.
Retrieve your HashiCups URL and open it in your browser.
Next steps
In this tutorial, you deployed an HCP Consul Dedicated server cluster, your choice of Kubernetes or virtual machine Consul clients, and a demo application. Then, you explored how the demo application leverages Consul service mesh and interacted with Consul using the CLI and UI.
In the next tutorial, you will interact with intentions to learn how to control service access within the service mesh.
To learn more about HCP Consul Dedicated, visit the HCP Consul Dedicated documentation. For additional runtimes and cloud providers, visit the following tutorials: