Skip to content
Tutorials Center
My learning

Topics

HashiCorp Consul Tutorial

Learn HashiCorp Consul step by step: 37 lessons in 9 chapters with examples, quizzes, diagrams and projects.

Start learning →

of lessons completed

Getting Started

  1. 1 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.
  2. 2 Consul Architecture: Agents, Gossip and Raft Understand how a Consul cluster works: server and client agents, the Serf gossip protocol, Raft consensus, quorum math, ports and the role of a datacenter.
  3. 3 Installing Consul and Running a Dev Agent Install the Consul binary on Linux, macOS, Windows or Docker, start a single-node dev agent, check members and open the UI. Includes a port-conflict checker.
  4. 4 The Consul CLI and HTTP API Learn how Consul's CLI wraps the HTTP API: endpoint families, environment variables, tokens, query parameters like stale and dc, and response headers.
  5. 5 Configuring a Consul Agent Write production-style Consul agent configuration in HCL: server and client files, retry_join, bootstrap_expect, bind addresses, merging rules and validation.

Service Discovery

  1. 6 Registering Services with Consul Register services with Consul using definition files, the CLI and the HTTP API. Learn service IDs, ports, addresses, anti-entropy and how to deregister cleanly.
  2. 7 Service Tags, Metadata and Weights Use Consul tags to filter instances, meta for descriptive data, and weights to steer DNS traffic. Covers canary and versioned lookups, enable_tag_override and limits.
  3. 8 The Consul DNS Interface Resolve services with Consul DNS on port 8600: the name formats for services, nodes, tags and datacenters, A versus SRV records, only_passing, TTLs and truncation.
  4. 9 Forwarding DNS to Consul (systemd-resolved, dnsmasq, CoreDNS) Make every program resolve .consul names by forwarding that domain from the system resolver to the Consul agent on port 8600, with systemd-resolved, dnsmasq, BIND or CoreDNS.
  5. 10 The Catalog and Health HTTP APIs Query Consul service discovery over HTTP: catalog versus health endpoints, passing filters, node lookups, filter expressions, external-service registration and client-side load balancing.
  6. 11 Prepared Queries and Failover Use Consul prepared queries to save a service lookup with tags, health rules, nearest-first sorting and datacenter failover, then call it from DNS or HTTP.

Key-Value and Config

  1. 12 The Consul Key-Value Store Store and read configuration in Consul's key-value store with the CLI and HTTP API: key hierarchies, base64 values, recurse, keys with separators, indexes and size limits.
  2. 13 Check-and-Set, Sessions and Distributed Locks Update Consul KV safely with check-and-set, use sessions with TTLs and behaviors, acquire and release locks, run consul lock, and build leader election with a stale-lock guard.
  3. 14 Watches and Blocking Queries React to Consul changes without polling: blocking queries with index and wait, X-Consul-Index rules, the consul watch command, watch types, handlers and event firing.
  4. 15 Configuration Patterns and Consul Template Organize Consul KV for real applications: key layout, defaults, feature flags and gradual rollout, then render live config files with Consul Template and envconsul.

Health Checks

  1. 16 Consul Health Check Types: HTTP, TCP, gRPC, Script, TTL, Alias Learn every kind of Consul health check, how each one maps results to passing, warning or critical, and how to attach checks to services and nodes safely.
  2. 17 Check Timing, TTLs and Avoiding Flapping Tune Consul health checks: interval, timeout, success_before_passing, failures_before_critical, initial_status, TTL heartbeats and deregister_critical_service_after, with detection-time math.
  3. 18 Health States, Node Checks and Maintenance Mode See how Consul combines checks into a service status, what serfHealth and node checks do, how to drain instances with consul maint, and how to alert on critical checks.
  4. 19 Designing Health Endpoints and Check Patterns Design health endpoints that work with Consul: liveness versus readiness, shallow versus deep checks, using 429 for degraded states, avoiding cascading failures and startup and shutdown flows.

Service Mesh

  1. 20 Service Mesh Concepts with Consul Learn what a service mesh is, how Consul service mesh secures service-to-service traffic with sidecar proxies, mutual TLS and identity certificates.
  2. 21 Sidecar Proxies and Upstreams in Consul Register a service with a sidecar proxy, declare upstreams with local bind ports, understand the sidecar port range and run Envoy with consul connect envoy.
  3. 22 Consul Intentions: Controlling Service Access Control which services may talk to each other with Consul intentions: allow and deny rules, wildcards, precedence, default policy and L7 permissions.
  4. 23 Consul Traffic Routing, Splitting and Resolution Shape mesh traffic with Consul config entries: service-router for L7 routing, service-splitter for canary releases and service-resolver for subsets and failover.

ACLs and Security

  1. 24 The Consul ACL System: Overview and Bootstrap Understand the Consul ACL system: tokens, policies, roles, default policy, enabling ACLs on servers and clients, bootstrapping the first management token.
  2. 25 Writing Consul ACL Rules and Policies Write Consul ACL rules for services, nodes, key-value paths, sessions and the agent: exact versus prefix matching, access levels, and creating policies with the CLI.
  3. 26 Consul ACL Tokens, Roles and Identities Create and manage Consul ACL tokens, group policies into roles, use service and node identities, set agent tokens and understand auth methods and token expiry.
  4. 27 Consul Gossip Encryption and TLS Secure a Consul cluster: generate a gossip key with consul keygen, rotate it with the keyring, create a CA and certificates with consul tls, and configure verification.

Multi-datacenter

  1. 28 Consul Datacenters and WAN Federation Connect Consul datacenters with WAN federation: LAN versus WAN gossip, the primary datacenter, joining with retry_join_wan, mesh gateways and ACL replication.
  2. 29 Cross-Datacenter Discovery and Failover in Consul Find services in other Consul datacenters with DNS and the HTTP API, use prepared queries for nearest and failover lookups, and fail over mesh traffic with resolvers.
  3. 30 Consul Cluster Peering Connect independent Consul clusters with cluster peering: generate and establish peering tokens, export services, write intentions for peers and compare with WAN federation.

Operations

  1. 31 Consul Raft, Quorum and Autopilot Understand how Consul servers elect a leader with Raft, why you need 3 or 5 servers, how quorum and fault tolerance work, and what Autopilot automates.
  2. 32 Consul Telemetry, Logs and Monitoring Monitor a Consul cluster: enable telemetry for Prometheus, watch the key Raft and Autopilot metrics, read logs with consul monitor and set practical alerts.
  3. 33 Consul Backups, Upgrades and Troubleshooting Operate Consul safely: take and restore snapshots, plan rolling upgrades with consul leave, handle failed servers and follow a checklist to troubleshoot common problems.

Projects and Practice

  1. 34 Project: Build a Service Registry Simulator Build a small Consul-style service registry in Python with registration, health checks, TTLs, round-robin discovery and prepared-query failover, then test it.
  2. 35 Project: Build an ACL Rule Parser and Checker Write a Python parser for Consul-style ACL rules and an authorizer that applies exact-over-prefix and longest-prefix matching, then lint policies for risky grants.
  3. 36 Project: An Intention Evaluator and Mesh Planner Build a Python tool that evaluates Consul-style intentions with precedence, checks an application's call graph against them and plans sidecar ports and canary splits.
  4. 37 Practice: Consul Mesh, Security and Operations Exercises Test your Consul skills with exercises on intentions, ACL rules, quorum, keyring rotation and failover, with runnable checkers and worked solutions.