Envoy HTTP流量管理 故障注入
来源:原创
时间:2019-12-01
作者:脚本小站
分类:云原生
故障注入:
注入延迟:
{
"type": "...", # 类型, 即将弃用;
"fixed_delay": "{...}", # 持续时长, 将请求转发至上游主机之前添加固定延迟;
"header_delay": "{...}", # 基于HTTP标头的指定控制故障延迟;
"percentage": "{...}" # 将注入迟延的 操作/连接/请求( operations/connections/requests) 的百分比,
# 即将错误注入到多大比例的请求操作上;
}注入请求终止:
{
"http_status": "...", # 用于中止HTTP请求的状态码, 必选参数;
"percentage": "{...}" # 将使用的错误代码中止的 请求/操作/连接 的百分比;
}响应报文的速率限制:
{
"fixed_limit": "{"limit_kbps": ...}", # 固定速率, 单位KiB/s;
"header_limit": "{...}", # 限制为HTTP首部的指定的速率;
"percentage": "{...}" # 将注入的速率限制为 操作/连接/请求( operations/connections/requests) 的百分比;
}注入请求终止:
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
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: local_service
http_filters:
- name: envoy.fault
config:
abort:
http_status: 503 # 响应码
percentage:
numerator: 10 # 故障比例为10/hundred
denominator: HUNDRED
- name: envoy.router
config: {}
clusters:
- name: local_service
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: local_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080注入延迟:
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
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: local_service
http_filters:
- name: envoy.fault
config:
delay:
type: fixed
fixed_delay: 10s # 延迟时间
percentage:
numerator: 10 # 延迟比率 10/handred
denominator: HUNDRED
- name: envoy.router
config: {}
clusters:
- name: local_service
connect_timeout: 0.25s
type: strict_dns
lb_policy: round_robin
load_assignment:
cluster_name: local_service
endpoints:
- lb_endpoints:
- endpoint:
address:
socket_address:
address: 127.0.0.1
port_value: 8080