These assets are provided to show how to configure Envoy outlier detection in HashiCorp Consul to implement a circuit breaker for an application in a service mesh.
- Docker Compose
- Docker
curl
The following files are provided as demo scripts:
start.sh: Starts Consul, three services (web,api-v1,api-v2) with proxies, and Prometheus (for metrics).fail.sh: Enables error rates forapi-v2service.success.sh: Disables error rates forapi-v2service for successful calls.request.sh: Make repeated API calls to thewebservice to trigger the circuit breaker.cleanup.sh: Removes all of the instances.
NOTE: DON'T FORGET that this demo requires Docker Compose!
-
Run
start.sh. This starts Consul in development mode and registers three services,web,api-v1, andapi-v2. It also starts Prometheus to aggregate metrics. -
Run
fail.sh. This toggles an error setting inapi-v2to mimic an error. -
Run
request.shto issue 100 API requests against thewebservice. Since outlier detection is enabled, you will find that the circuit breaker will open and divert all traffic toapi-v1while occasionally sending a request toapi-v2to check its availability. -
In another terminal, run
success.sh. This will close the circuit breaker and once more divert traffic to bothapi-v1andapi-v2.
Finally, run cleanup.sh to re-set your environment so that you can repeat the demo as necessary.
WARNING: The
cleanup.shremoves all instances.