Connect services on Windows workloads to Consul service mesh
A significant number of critical enterprise applications and services operate on Windows servers. As network topologies grow more complicated and security requirements evolve, it is increasingly important to integrate Windows workloads with a service mesh.
Consul is the only service mesh to support both Windows and Linux, enabling you to effectively manage your network from a single control plane. Consul service mesh provides your Windows workloads capabilities such as traffic management, zero trust security, resiliency, policy, enhanced observability, and secure communication across any platform or runtime.
Note
This capability is available in beta for Consul 1.15.0 preview with Windows Server 2019 VMs and Envoy versions 1.23.0, and 1.22.2. The beta version supports all Consul open source features for a single Consul datacenter.
In this tutorial, you will deploy a Consul server cluster, two Windows VMs pre-configured with Consul, Envoy, and an example workload. In the process, you will learn how to configure your existing Windows workloads with Consul and Envoy to leverage Consul service mesh.
Prerequisites
The tutorial assumes that you are familiar with Consul and its core functionality. If you're new to Consul, refer to the Consul Getting Started tutorials collection.
For this tutorial, you will need:
- An HCP account configured for use with Terraform
- An AWS account configured for use with Terraform
- consul 1.15.0-preview
- terraform >= 1.2
- git >= 2.0
Confirm that you have configured your HCP and AWS credentials correctly for Terraform to use.
Clone example repository
Clone the GitHub repository containing the configuration files and resources.
Navigate to the cloned repository.
Deploy infrastructure
This tutorial deploys an HCP Consul Dedicated cluster, supporting AWS networking infrastructure (VPC, subnets, etc), and two Windows servers. The Windows servers are pre-configured with Consul, Envoy, and fake-service
. In the next section, you will go through the provisioning steps required to enable Consul client agents on your Windows servers.
Initialize the Terraform project to download the necessary providers and modules.
Then, deploy the resources. Confirm the run by entering yes
.
This step takes about 15 minutes. While waiting, read the next section to learn how to configure Consul, Envoy, and service definitions on a Windows virtual machine (VM).
Review Consul client configuration
The repository contains three main components that enable Consul on Windows workloads:
- The
windows.tf
file contains the configuration for the Windows virtual machine. - The
templates/consul-client-agent.tftpl
file is a PowerShell script Terraform uses to install the Consul and Envoy binaries, configure the client agents, start Consul and Envoy, and register the services (fake-service
frontend or backend) to Consul. - The
services
directory contains the Consul service definitions forfake-service
and an intentions file to enable service-to-service communication between thefake-service
backend and frontend.
Open windows.tf
and find the aws_instance.fakeservice
resource.
This resource defines a Windows Server 2019 VM with the following parameters:
- The
for_each
parameter creates a set of service names from the service definitions in theservices
file. Terraform uses this set to deploy a Windows VM with the service definitions pre-configured. This tutorial's Terraform configuration assumes a dedicated VM for each service. - The
user_data
parameter specifies the file the instance loads automatically when it launches. Notice it uses thetemplates/consul-client-agent.tftpl
file as a base, populating it with values to configure Consul and Envoy.
These parameters configure the Consul client agent to connect to and interact with the HCP Consul Dedicated cluster.
Open templates/consul-client-agent.tftpl
. Review the comments in the file for an explanation of the steps required to configure Consul on Windows workloads. The values in ${}
map to the EC2 instance's user_data
parameter.
Unlike Linux and MacOS, you cannot bootstrap Envoy using the consul connect envoy
command. Instead, you must explicitly use the -bootstrap
option, and specify your Consul ACL token and a valid access log path. The consul-client-agent.tftpl
does the following to generate the Envoy configuration file.
Open services/fakeservice-backend.json
. This file defines a Consul service and a healthcheck for the fake-service
backend. The tutorial Terraform configuration prepopulates the service definitions (must be a JSON file) in the services
directory in an unique Windows VM.
Configure Consul CLI
Once Terraform completes, it returns similar output to the following:
The password_data
output contains passwords to remote access into each Windows VM. If you are interested in learning how to connect to a Windows VM using RDP, visit the AWS documentation.
You will now configure the Consul CLI to connect to your HCP Consul Dedicated cluster by retrieving the HCP Consul Dedicated cluster address and root token.
First, retrieve the HCP Consul Dedicated cluster URL and export it as an environment variable named CONSUL_HTTP_ADDR
.
Then, retrieve the root token and export it as an environment variable named CONSUL_HTTP_TOKEN
.
Confirm your Consul CLI connects to your HCP Consul Dedicated cluster by retrieving the cluster's members. You should observe one Consul server and two Consul clients.
Verify services
List the services registered in Consul. Notice this includes the fake-service
backend and frontend, in addition to their respective Envoy sidecar proxies.
List the fake-service
frontend service's address. Open the address in your browser.
You will find something similar to the following. Notice that the service is up, but is unable to connect to its backend. This is expected behavior since you have not yet defined any service intentions.
Create Consul service intentions
In this section, you will create a Consul intention to enable the fake-service
frontend and backend services to interact with each other.
Open services/service-intentions.hcl
. This file defines the service intention that allows traffic from fakeservice-frontend
to fakeservice-backend
.
Create the service intentions to allow the services to interact with each other.
Verify connected services
Refresh the frontend service in your browser. You should find something similar to the following. The frontend service can now interact with the backend service.
You have successfully deployed and configured two services on Windows workloads to Consul service mesh.
Clean up your infrastructure
Before moving on, destroy the infrastructure you created in this tutorial. Confirm the destroy with a yes
.
Next steps
In this tutorial, you deployed a Consul server cluster and two Windows VMs, pre-configured with Consul, Envoy, and fake-service
. In the process, you learned how to configure your existing Windows workload with Consul and Envoy to leverage Consul service mesh.
For more information on topics covered in this tutorial, check out the following resources.
- Complete the Upgrade Services with Canary Deployments tutorial to learn how to use Consul's service splitting capabilities to manage service traffic
- Read the service definition documentation to learn more about how to register services to Consul
- Read the service intention documentation to learn more about how to enable service to service communication