Deploy Consul on Windows nodes in Kubernetes
Consul is a service networking solution that enables teams to manage secure network connectivity between services and across on-prem and multi-cloud environments and runtimes. Consul offers service discovery, service mesh, traffic management, and automated updates to network infrastructure devices. Check out the What is Consul? page to learn more.
In this tutorial, you will deploy a Consul datacenter onto a Kubernetes cluster containing Windows and Linux nodes. After deploying Consul, you will interact with Consul using the CLI, UI, and/or the API. You will then deploy a demo application and integrate it with Consul service mesh.
In this tutorial, you will:
- Deploy an Elastic Kubernetes Service (EKS) cluster with Terraform
- Install Consul using Helm
- Deploy a demo application
- Configure your terminal to communicate with the Consul datacenter
- View Consul services with the CLI, UI, and/or API
Note
The Consul Kubernetes on Windows nodes feature is a preview release meant for testing purposes. This release is designed to be run on EKS and does not currently support GKE deployments.
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 AWS account configured for use with Terraform
- aws-cli >= 2.0
- terraform >= 1.0
- consul >= 1.14.4
- git >= 2.0
- helm >= 3.0
- kubectl <= 1.24
Clone GitHub repository
In this section, you will clone two repositories; one containing the alpha release of the Consul Helm chart that supports Windows Kubernetes nodes, and the other containing the configuration files and resources for building your tutorial environment.
Clone the alpha release Helm chart
Clone the Consul Kubernetes GitHub repository.
Change into the directory of the repository you cloned.
Checkout the branch containing the alpha release of the Consul Helm chart that supports Windows Kubernetes nodes.
Set this directory to the CONSUL_HELM_DIR
environment variable.
Clone configuration files and resources
Open a separate terminal and clone the GitHub repository containing the configuration files and resources.
Change into the directory that contains the complete configuration files for this tutorial.
Create infrastructure
With these Terraform configuration files, you are ready to deploy your infrastructure.
Issue the terraform init
command from your working directory to download the necessary providers and initialize the backend.
Then, deploy the resources. Confirm the run by entering yes
.
Note
The Terraform deployment could take up to 15 minutes to complete. Feel free to explore the next sections of this tutorial while waiting for the environment to complete initialization.
Connect to your infrastructure
Kubernetes stores cluster connection information in a file called kubeconfig
. You can retrieve the Kubernetes configuration settings for your EKS cluster and merge them into your local kubeconfig
file by issuing the following command:
Review and deploy Consul datacenter
You will now review the values file for deploying a Consul datacenter in your Kubernetes cluster using Helm.
Open helm/values-v1.yaml
. This file defines the Consul datacenter you will deploy to Kubernetes. Review the comments in the file for an explanation of each parameter.
Note
The Consul Kubernetes on Windows nodes feature is a preview release meant for testing purposes. This release does not currently support Consul ACLs or TLS.
For a complete list of Helm chart parameters and configuration, refer to the Consul Helm chart documentation.
Deploy Consul datacenter
Deploy a Consul datacenter to your Kubernetes environment with the alpha release Helm chart you cloned earlier.
Install Consul to your Kubernetes cluster with the Helm chart. Notice that this command installs Consul into the consul
namespace.
Verify Helm successfully created the Consul resources.
Deploy the counting and dashboard demo application
In this section, you will deploy the demo application to explore Consul's service mesh features.
The nodeSelector
attribute defines which Kubernetes nodes will host the workload. In this scenario, the counting service will run on Linux Kubernetes nodes and the dashboard service will run on Windows Kubernetes nodes.
Deploy the counting and dashboard demo application.
Tip
The initial demo application deployment will take about 10-15 minutes to complete. Windows containers are much larger than Linux containers and generally take more time to reach a running status.Check the pods to confirm they are all running.
Test the demo application
In a new terminal window, port forward the dashboard
service to locally view the demo application's dashboard.
Open http://localhost:9002 in your browser.
The dashboard
UI shows it is connected to the counting
backend. This indicates that the dashboard
service running on the Kubernetes Linux node and the counting
service running on the Kubernetes Windows node can communicate through Consul service mesh.
Configure your CLI to interact with Consul datacenter
In this section, you will set environment variables in your terminal so your Consul CLI can interact with your Consul datacenter. The Consul CLI reads these environment variables for behavior defaults and will reference these values when you run consul
commands.
Set the Consul destination address. By default, Consul runs on port 8500
for http
and 8501
for https
.
View Consul services
In this section, you will view your Consul services with the CLI, UI, and/or API to explore the details of your service mesh.
In your terminal, run the CLI command consul catalog services
to return the list of services registered in Consul.
Agents run in either server or client mode. Server agents store all state information, including service and node IP addresses, health checks, and configuration. Client agents are lightweight processes that make up the majority of the datacenter. They report service health status to the server agents. Clients must run on every pod where services are running.
Run the CLI command consul members
to return the list of Consul agents in your environment.
All services listed in your Consul catalog are empowered with Consul's service discovery capabilities that simplify scalability challenges and improve application resiliency. Review the Service Discovery overview page to learn more.
Clean up
Destroy the Terraform resources to clean up your environment. Confirm the destroy operation by inputting yes
.
Note
Due to race conditions with the various cloud resources created in this tutorial, you may need to run the destroy
operation twice to ensure all resources have been properly removed.
Next steps
In this tutorial, you integrated Consul into your environment containing both Linux and Windows Kubernetes nodes. After deploying Consul, you interacted with Consul using the CLI, UI, and/or API.
For more information about the topics covered in this tutorial, refer to the following resources: