root@ceph-teamplate:~/circuit_breaker# cat docker-compose.yaml
version: '3.3'
services:
envoy:
image: envoyproxy/envoy-alpine:v1.11.1
volumes:
- ./front-envoy.yaml:/etc/envoy/envoy.yaml
networks:
- envoymesh
expose:
- "80"
- "9901"
service_blue:
image: ikubernetes/servicemesh-app:latest
networks:
envoymesh:
aliases:
- service_blue
- colored
environment:
- SERVICE_NAME=blue
expose:
- "80"
service_green:
image: ikubernetes/servicemesh-app:latest
networks:
envoymesh:
aliases:
- service_green
- colored
environment:
- SERVICE_NAME=green
expose:
- "80"
service_red:
image: ikubernetes/servicemesh-app:latest
networks:
envoymesh:
aliases:
- service_red
- colored
environment:
- SERVICE_NAME=red
expose:
- "80"
service_gray:
image: ikubernetes/servicemesh-app:latest
volumes:
- ./envoy.yaml:/etc/envoy/envoy.yaml
networks:
envoymesh:
aliases:
- service_gray
- myservice
environment:
- SERVICE_NAME=gray
expose:
- "80"
service_black:
image: ikubernetes/servicemesh-app:latest
volumes:
- ./envoy.yaml:/etc/envoy/envoy.yaml
networks:
envoymesh:
aliases:
- service_black
- myservice
environment:
- SERVICE_NAME=black
expose:
- "80"
networks:
envoymesh: {}
root@ceph-teamplate:~/circuit_breaker# cat front-envoy.yaml
admin:
access_log_path: "/dev/null"
address:
socket_address:
address: 0.0.0.0
port_value: 9901
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
name: listener_http
filter_chains:
- filters:
- name: envoy.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: backend
domains:
- "*"
routes:
- match:
prefix: "/service/colorless"
route:
cluster: webcluster2
- match:
prefix: "/"
route:
cluster: webcluster1
http_filters:
- name: envoy.router
clusters:
- name: webcluster1
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: webcluster1
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: colored
port_value: 80
circuit_breakers:
thresholds:
max_connections: 1
max_pending_requests: 1
max_retries: 3
- name: webcluster2
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: webcluster2
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: myservice
port_value: 80
outlier_detection:
interval: "1s"
consecutive_5xx: "3"
consecutive_gateway_failure: "3"
base_ejection_time: "10s"
enforcing_consecutive_gateway_failure: "100"
max_ejection_percent: "30"
success_rate_minimum_hosts: "2"
root@ceph-teamplate:~/circuit_breaker# cat envoy.yaml
static_resources:
listeners:
- address:
socket_address:
address: 0.0.0.0
port_value: 80
name: listener_http
filter_chains:
- filters:
- name: envoy.http_connection_manager
typed_config:
"@type": type.googleapis.com/envoy.config.filter.network.http_connection_manager.v2.HttpConnectionManager
codec_type: auto
stat_prefix: ingress_http
route_config:
name: local_route
virtual_hosts:
- name: service
domains:
- "*"
routes:
- match:
prefix: "/"
route:
cluster: localservice
http_filters:
- name: envoy.router
typed_config: {}
clusters:
- name: localservice
connect_timeout: 0.25s
type: STRICT_DNS
lb_policy: ROUND_ROBIN
load_assignment:
cluster_name: localservice
endpoints:
lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080
circuit_breakers:
thresholds:
max_connections: 1
max_pending_requests: 1
max_retries: 2
curl 172.23.0.3:80/service/colorless
https://github.com/fortio/fortio
curl -L https://github.com/fortio/fortio/releases/download/v1.17.0/fortio-linux_x64-1.17.0.tgz \
| sudo tar -C / -xvzpf -
# or the debian package
wget https://github.com/fortio/fortio/releases/download/v1.17.0/fortio_1.17.0_amd64.deb
dpkg -i fortio_1.17.0-1_amd64.deb
# or the rpm
rpm -i https://github.com/fortio/fortio/releases/download/v1.17.0/fortio-1.17.0-1.x86_64.rpm
fortio load -c 4 -qps 0 -n 100 -loglevel Warning http://172.23.0.3:80/service/colored
Code 200 : 97 (97.0 %)
Code 503 : 3 (3.0 %)
root@ceph-teamplate:~/circuit_breaker# fortio load -c 4 -qps 0 -n 100 -loglevel Warning http://172.23.0.3:80/service/colorless
Code 200 : 95 (95.0 %)
Code 503 : 5 (5.0 %)
root@ceph-teamplate:~/circuit_breaker# curl -s 172.23.0.3:9901/stats | grep cluster.webcluster1
cluster.webcluster1.external.upstream_rq_200: 1226
cluster.webcluster1.external.upstream_rq_2xx: 1226
cluster.webcluster1.external.upstream_rq_404: 2
cluster.webcluster1.external.upstream_rq_4xx: 2
cluster.webcluster1.external.upstream_rq_503: 30
cluster.webcluster1.external.upstream_rq_5xx: 30