Overview
This template provides a production‑ready HashiCorp Consul instance as a Monk runnable. You can:- Run it directly to get a managed Consul container with sensible defaults
- Inherit it in your own runnable to seamlessly add service discovery and configuration management to your infrastructure
What this template manages
- Consul container (
consulimage, configurable tag) - Web UI and HTTP API on port 8500
- Service discovery and health checking
- Key/value store
- DNS interface on port 8600
- Optional persistent volumes for data
Quick start (run directly)
- Load templates
- Run Consul with defaults
- Access the web interface
http://localhost:8500.
Configuration
The template provides both base and node configurations. You can extend the template with your own variables or environment settings when inheriting. The base template uses sensible defaults and can be customized via inheritance:${monk-volume-path}/consul/node on the host.
Available templates
consul/base- Base Consul configurationconsul/node- Consul node (inherits from base)
Use by inheritance (recommended for infrastructure)
Inherit the Consul runnable in your service mesh or microservices infrastructure. Example:Ports and connectivity
- Service:
consulon TCP port8500(HTTP API and Web UI) - DNS interface: UDP/TCP port
8600 - Serf LAN: TCP/UDP port
8301 - Serf WAN: TCP/UDP port
8302 - Server RPC: TCP port
8300 - From other runnables in the same process group, use
connection-hostname("\<connection-name>")to resolve the Consul host.
Features
- Service Discovery: Consul clients can register services and other clients can discover them via DNS or HTTP API
- Health Checking: Consul monitors service health and only routes to healthy instances
- Key/Value Store: Flexible key/value store for dynamic configuration and feature flags
- Multi-Datacenter: Consul supports multiple datacenters out of the box
- Service Mesh: Connect services securely with automatic TLS encryption and identity-based authorization
Persistence
- Data path:
${monk-volume-path}/consul/node:/consul/data - Consul stores service registry, health checks, key/value data, and cluster state in this directory
- This volume ensures data persists across container restarts
Related templates
- See other templates in this repository for complementary services
- Combine with monitoring tools (
prometheus-grafana/) for observability - Integrate with your application stack as needed
Troubleshooting
- Ensure all required ports (8500, 8600, 8301, 8302, 8300) are available and not blocked by firewall
- If Consul fails to start, check that the datacenter configuration matches across all nodes in a cluster
- For cluster setups, verify that
consul-bootstrap-expectmatches the actual number of server nodes - Check logs:
- Access the web UI to monitor cluster health:
http://localhost:8500 - Verify Consul agent status inside the container:
- If services aren’t registering, ensure the Consul agent is running in the correct mode (server vs client)