consul
by HashiCorp
Official HashiCorp Consul Chart
About this chart
Consul on Kubernetes Helm Chart
We're looking for feedback on how folks are using Consul on Kubernetes. Please fill out our brief survey!
Overview
This is the Official HashiCorp Helm chart for installing and configuring Consul on Kubernetes. This chart supports multiple use cases of Consul on Kubernetes, depending on the values provided.
For full documentation on this Helm chart along with all the ways you can use Consul with Kubernetes, please see the Consul and Kubernetes documentation.
:warning: Please note: We take Consul's security and our users' trust very seriously. If you believe you have found a security issue in Consul K8s, please responsibly disclose by contacting us at [email protected].
Features
-
Consul Service Mesh: Run Consul Service Mesh on Kubernetes. This feature injects Envoy sidecars and registers your Pods with Consul.
-
Catalog Sync: Sync Consul services into first-class Kubernetes services and vice versa. This enables Kubernetes to easily access external services and for non-Kubernetes nodes to easily discover and access Kubernetes services.
Installation
consul-k8s is distributed in multiple forms:
-
The recommended installation method is the official Consul Helm chart. This will automatically configure the Consul and Kubernetes integration to run within an existing Kubernetes cluster.
-
A Docker image
hashicorp/consul-k8s-control-planeis available. This can be used to manually runconsul-k8s-control-planewithin a scheduled environment. -
Consul K8s CLI, distributed as
consul-k8s, can be used to install and uninstall Consul Kubernetes. See the Consul K8s CLI Reference for more details on usage.
Prerequisites
The following pre-requisites must be met before installing Consul on Kubernetes.
- Kubernetes 1.27.x - 1.30.x - This represents the earliest versions of Kubernetes tested. It is possible that this chart works with earlier versions, but it is untested.
- Helm install
- Helm 3.6+ for Helm based installs.
- Consul K8s CLI based install
kubectlconfigured to authenticate to a Kubernetes cluster with a validkubeconfigfile.brew,yum, oraptpackage manager on your local machine
CLI
The Consul K8s CLI is the easiest way to get up and running with Consul on Kubernetes. See Install Consul on K8s CLI for more details on installation, and refer to Consul on Kubernetes CLI Reference for more details on subcommands and a list of all available flags for each subcommand.
-
Install the HashiCorp tap, which is a repository of all Homebrew packages for HashiCorp:
brew tap hashicorp/tap -
Install the Consul K8s CLI with hashicorp/tap/consul formula.
brew install hashicorp/tap/consul-k8s -
Issue the install subcommand to install Consul on Kubernetes:
consul-k8s install
Helm
The Helm chart is ideal for those who prefer to use Helm for automation for either the installation or upgrade of Consul on Kubernetes. The chart supports multiple use cases of Consul on Kubernetes, depending on the values provided. Detailed installation instructions for Consul on Kubernetes are found here.
-
Add the HashiCorp Helm repository:
helm repo add hashicorp https://helm.releases.hashicorp.com -
Ensure you have access to the Consul Helm chart and you see the latest chart version listed. If you have previously added the HashiCorp Helm repository, run
helm repo update.helm search repo hashicorp/consul -
Now you're ready to install Consul! To install Consul with the default configuration using Helm 3.2 run the following command below. This will create a
consulKubernetes namespace if not already present, and install Consul on the dedicated namespace.helm install consul hashicorp/consul --set global.name=consul --create-namespace -n consul
Please see the many options supported in the values.yaml
file. These are also fully documented directly on the
Consul website.
API Gateway Probe Configuration
You can configure Kubernetes health probes (liveness, readiness, and startup) for individual API Gateways using annotations. This allows you to customize probe behavior per-Gateway rather than using a class-wide configuration.
Example Gateway with Custom Probes
apiVersion: gateway.networking.k8s.io/v1beta1
kind: Gateway
metadata:
name: example-gateway
namespace: consul
annotations:
# Configure liveness probe (JSON format)
consul.hashicorp.com/liveness-probe: |
{
"httpGet": {
"path": "/ready",
"port": 20000
},
"initialDelaySeconds": 10,
"periodSeconds": 10,
"timeoutSeconds": 1,
"successThreshold": 1,
"failureThreshold": 3
}
# Configure readiness probe (JSON format)
consul.hashicorp.com/readiness-probe: |
{
"httpGet": {
"path": "/ready",
"port": 20000
},
"initialDelaySeconds": 5,
"periodSeconds": 10
}
# Configure startup probe (JSON format)
consul.hashicorp.com/startup-probe: |
{
"tcpSocket": {
"port": 20000
},
"periodSeconds": 2,
"failureThreshold": 30
}
spec:
gatewayClassName: consul
listeners:
- name: http
protocol: HTTP
port: 8080
Supported Probe Annotations
consul.hashicorp.com/liveness-probe: Liveness probe configuration (JSON)consul.hashicorp.com/readiness-probe: Readiness probe configuration (JSON)consul.hashicorp.com/startup-probe: Startup probe configuration (JSON)
Each annotation accepts a JSON object following the Kubernetes Probe specification. Supported probe handlers: httpGet, tcpSocket, exec, grpc.
Note: Liveness and startup probes must have successThreshold: 1 per Kubernetes requirements. The controller will automatically normalize this value if a different value is provided.
Tutorials
You can find examples and complete tutorials on how to deploy Consul on Kubernetes using Helm on the HashiCorp Learn website.
Deploy consul with OpenTenant
Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has consul on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.
- Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
- Place the chartconsul is pinned at v2.1.0 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
- ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below opentenant validate opentenant.yaml terraform init && terraform apply