Skip to content
Tutorials Center
My learning

Topics

Lesson 1 of 37 Β· Getting Started

What Is HashiCorp Consul?

Meet HashiCorp Consul: the problems it solves (service discovery, health checking, key-value config, service mesh) and how this course teaches it without a live cluster.

Modern applications are rarely one program. A web shop might be a dozen services (cart, payments, search, inventory) that start, stop, scale and move between machines all day. The hard question is simple to ask: how does service A find a healthy copy of service B right now? HashiCorp Consul is a tool built to answer it, and a few related questions, in one consistent way.

This lesson explains what Consul is, what it gives you, and how this course is organized. Consul is a server product that needs real processes and networks, so it cannot run inside the browser. Everything about Consul itself (commands, configuration files, API calls) is shown as read-only text. Where an idea can be demonstrated with ordinary code, the lesson includes a clearly labelled stand-in program in Python that you can run and edit.

The problem: addresses that keep changing

In a classic setup you might hard-code payments.internal:8443 into a config file. That works until:

  • the service moves to a new machine or container and its IP address changes;
  • you run three copies for capacity and need to spread traffic across them;
  • one copy crashes and callers keep sending requests to it;
  • a new environment (staging, a second region) needs different addresses.

Editing config files by hand does not scale. A service registry keeps a live list of "who is running where, and are they healthy". Consul is such a registry, plus much more.

What Consul provides

Consul groups its features into four areas, which map to the chapters of this course.

Four jobs, one tool

Service discovery Find healthy instances by name.
Health checks Remove broken instances.
Key-value store Share config and flags.
Service mesh Secure, identity-based traffic.

Plus ACLs, multi-datacenter support and operations tooling.

1 / 2
  1. Service discovery. Services register a name (payments) and an address. Callers look the name up through a DNS query or an HTTP API and get only the instances that are alive.
  2. Health checking. Consul runs checks (an HTTP request, a TCP connect, a script, a heartbeat) and removes failing instances from answers automatically.
  3. Key-value store. A small, strongly consistent store for configuration, feature flags and coordination (such as leader election with locks).
  4. Service mesh (Consul Connect). Sidecar proxies give every service a cryptographic identity, encrypt traffic with mutual TLS, and enforce who may talk to whom with intentions.

Consul also supports multiple datacenters, access control lists (ACLs), and a UI and API for operating all of it.

How a lookup looks

Suppose a service called web is registered on three machines, and one of them fails its health check. A DNS lookup for web.service.consul returns only the two good addresses. Nobody edited a file; the failing copy simply dropped out.

flowchart LR
  C["Caller"] -->|"dig web.service.consul"| A["Consul agent"]
  A --> R[("Service catalog")]
  R --> W1["web 10.0.1.5 (passing)"]
  R --> W2["web 10.0.1.6 (passing)"]
  R -.-> W3["web 10.0.1.7 (critical, hidden)"]

The catalog knows three instances, but only the passing ones are returned.

Where Consul fits

Consul is not a container orchestrator (that is Kubernetes or Nomad) and not a load balancer on its own. It is the source of truth about service locations and health, which orchestrators, proxies and your own code can read. It runs anywhere: virtual machines, bare metal, containers and Kubernetes. It is one of several tools from HashiCorp, alongside Terraform for provisioning infrastructure. Terraform builds the machines; Consul tells the running programs how to find each other.

Consul is source-available software distributed by HashiCorp (now part of IBM). A free community edition and paid enterprise features both exist; this course focuses on concepts and features that are the same in the open-source distribution, and flags enterprise-only ideas when they come up.

A first stand-in: a tiny service registry

The program below is not Consul. It is a toy dictionary-based registry that mimics the register-then-query idea, so you can see the data flow before meeting the real commands. Try marking an instance unhealthy and querying again.

Python Stand-in: a toy service registry

Press Run (or Ctrl + Enter) to see the result here.

Program input Β· what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Real Consul adds what the toy lacks: replication across servers so the registry survives failures, automatic health probing, a DNS interface, and security. The next lesson shows how it is built.

Terms you will meet

Term Meaning
Agent The Consul process that runs on every machine in the cluster
Server agent An agent that stores data and takes part in consensus
Client agent A lightweight agent that forwards requests to servers
Datacenter A group of agents on a fast network, one cluster
Catalog The registry of nodes and services
Intention A mesh rule that allows or denies one service calling another

Version numbers, UI labels and some defaults change between Consul releases. This course teaches the stable ideas and the commands that have been consistent across recent 1.x versions; check the release notes of the version you run.

Check your understanding

Quick check Β· 4 questions

of 4 answered You scored / 4 Β· perfect!

  1. 1. What core problem does Consul's service discovery solve?

    Consul keeps a live catalog of services and their health, so callers can look up healthy instances by name instead of hard-coded addresses.
  2. 2. A web instance fails its health check. What happens to a DNS query for web.service.consul?

    By default Consul answers only with instances whose checks pass; it does not restart anything.
  3. 3. Which Consul feature provides mutual TLS between services?

    Connect uses sidecar proxies with service identities and mutual TLS, controlled by intentions.
  4. 4. Why does this course use Python stand-ins?

    Consul needs real processes and networking. Its commands are shown read-only, and runnable Python programs model the concepts.

Summary

  • Consul is a registry and coordination tool: service discovery, health checking, a key-value store and a service mesh.
  • Callers query by service name (DNS or HTTP) and receive only healthy instances.
  • Every machine runs an agent; servers hold the data, clients forward requests.
  • Consul does not schedule containers; it is the source of truth other tools read.
  • On this site Consul itself is read-only; stand-ins are labelled and runnable.

Next: Consul Architecture: Agents, Gossip and Raft