diff --git a/examples/ext_authz/config/grpc-service/v3.yaml b/examples/ext_authz/config/grpc-service/v3.yaml index 992365eba5e0..48f184cf2432 100644 --- a/examples/ext_authz/config/grpc-service/v3.yaml +++ b/examples/ext_authz/config/grpc-service/v3.yaml @@ -49,31 +49,37 @@ static_resources: route_config: name: local_route virtual_hosts: - - name: upstream + - name: httpbin domains: - - "*" + #curl -v -H "Host: httpbin.org" 127.0.0.1:8000/uuid + - "httpbin.org" routes: - match: - prefix: "/httpbin" + prefix: "/" route: - cluster: httpbin + cluster: httpbin + + - name: upstream + domains: + - "*" + routes: - match: prefix: "/" route: cluster: upstream-service - http_filters: - # - name: envoy.filters.http.ext_authz - # typed_config: - # "@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz - # grpc_service: - # envoy_grpc: - # cluster_name: ext_authz-grpc-service - # timeout: 0.250s - # transport_api_version: V3 - - - name: envoy.filters.http.router + - name: envoy.filters.http.ext_authz + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.ext_authz.v3.ExtAuthz + grpc_service: + envoy_grpc: + cluster_name: ext_authz-grpc-service + timeout: 0.250s + transport_api_version: V3 + - name: envoy.filters.http.router + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router clusters: - name: upstream-service connect_timeout: 0.25s @@ -91,6 +97,7 @@ static_resources: - name: httpbin connect_timeout: 5000s type: strict_dns + dns_refresh_rate: 60s lb_policy: round_robin load_assignment: cluster_name: httpbin @@ -101,18 +108,6 @@ static_resources: socket_address: address: httpbin.org port_value: 80 - # - name: upstream-service - # type: STRICT_DNS - # lb_policy: ROUND_ROBIN - # load_assignment: - # cluster_name: upstream-service - # endpoints: - # - lb_endpoints: - # - endpoint: - # address: - # socket_address: - # address: upstream-service - # port_value: 8080 - name: ext_authz-grpc-service type: STATIC @@ -135,4 +130,4 @@ static_resources: address: socket_address: address: 9.134.189.148 - port_value: 9001 + port_value: 9001 diff --git a/examples/local-ratelimit/ratelimit-envoy.yaml b/examples/local-ratelimit/ratelimit-envoy.yaml new file mode 100644 index 000000000000..9444aef40449 --- /dev/null +++ b/examples/local-ratelimit/ratelimit-envoy.yaml @@ -0,0 +1,102 @@ +static_resources: + listeners: + - name: main + address: + socket_address: + address: 0.0.0.0 + port_value: 8000 + filter_chains: + - filters: + - name: envoy.filters.network.http_connection_manager + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager + codec_type: AUTO + stat_prefix: ingress_http + route_config: + name: local_route + virtual_hosts: + - name: httpbin + domains: + - "httpbin.org" + routes: + #curl -v -H "Host: httpbin.org" 127.0.0.1:8000/headers + - match: + prefix: "/headers" + route: + cluster: httpbin + #curl -v -H "Host: httpbin.org" 127.0.0.1:8000/uuid + - match: + prefix: "/" + route: + cluster: httpbin + + # typed_per_filter_config 会覆盖 http_filters 下面的配置,但是实际的 filter 还要在 http_filters 配置一下,仅仅在 typed_per_filter_config 配置是不会创建 filter 对象的 + typed_per_filter_config: + envoy.filters.http.local_ratelimit: + "@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit + stat_prefix: http_local_rate_limiter + token_bucket: + max_tokens: 2 + tokens_per_fill: 2 + fill_interval: 10s + filter_enabled: + runtime_key: local_rate_limit_enabled + default_value: + numerator: 100 + denominator: HUNDRED + filter_enforced: + runtime_key: local_rate_limit_enforced + default_value: + numerator: 100 + denominator: HUNDRED + response_headers_to_add: + - append: false + header: + key: x-local-rate-limit-per-route + value: 'true' + + http_filters: + - name: envoy.filters.http.local_ratelimit + # 下面的配置相当于是 filter 在此 listener 下面的全局配置 + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.local_ratelimit.v3.LocalRateLimit + stat_prefix: http_local_rate_limiter + token_bucket: + max_tokens: 5 + tokens_per_fill: 3 + fill_interval: 10s + filter_enabled: + runtime_key: local_rate_limit_enabled + default_value: + numerator: 100 + denominator: HUNDRED + filter_enforced: + runtime_key: local_rate_limit_enforced + default_value: + numerator: 100 + denominator: HUNDRED + response_headers_to_add: + - append: false + header: + key: x-local-rate-limit + value: 'true' + + - name: envoy.filters.http.router + typed_config: + "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router + + clusters: + - name: httpbin + connect_timeout: 5000s + type: strict_dns + dns_refresh_rate: 60s + lb_policy: round_robin + load_assignment: + cluster_name: httpbin + endpoints: + - lb_endpoints: + - endpoint: + address: + socket_address: + address: httpbin.org + port_value: 80 \ No newline at end of file