#HashiCorp Consul

Service discovery and service mesh.


#Features

FeatureDescription
Service DiscoveryFind services by name
Health CheckingMonitor service health
KV StoreConfiguration storage
ConnectService mesh with mTLS

#Installation

bash
1# Docker
2docker run -d --name consul \
3  -p 8500:8500 \
4  -p 8600:8600/udp \
5  consul agent -server -bootstrap -ui -client=0.0.0.0
6
7# UI: http://localhost:8500

#Service Registration

json
1{
2  "service": {
3    "name": "web",
4    "port": 8080,
5    "check": {
6      "http": "http://localhost:8080/health",
7      "interval": "10s"
8    }
9  }
10}

#Consul Connect (Service Mesh)

hcl
1# Enable Connect
2service {
3  name = "web"
4  port = 8080
5  connect {
6    sidecar_service {}
7  }
8}

[!TIP] Pro Tip: Consul is great for hybrid service discovery and mesh!