apiVersion: networking.istio.io/v1alpha3 kind: EnvoyFilter metadata: name: httpbin-global-ratelimit spec: workloadSelector: # select by label in the same namespace labels: app: httpbin configPatches: # The Envoy config you want to modify - applyTo: HTTP_FILTER match: context: SIDECAR_INBOUND listener: filterChain: filter: name: "envoy.filters.network.http_connection_manager" subFilter: name: "envoy.filters.http.router" patch: operation: INSERT_BEFORE # Adds the Envoy Rate Limit Filter in HTTP filter chain. value: name: envoy.filters.http.ratelimit typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.ratelimit.v3.RateLimit # domain can be anything! Match it to the ratelimter service config domain: productpage-ratelimit failure_mode_deny: true timeout: 10s rate_limit_service: grpc_service: envoy_grpc: cluster_name: outbound|8081||ratelimit.istio-system.svc.cluster.local authority: ratelimit.istio-system.svc.cluster.local transport_api_version: V3 --- apiVersion: networking.istio.io/v1alpha3 kind: EnvoyFilter metadata: name: httpbin-set-ratelimit-filter-state spec: workloadSelector: # select by label in the same namespace labels: app: httpbin configPatches: # The Envoy config you want to modify - applyTo: HTTP_FILTER match: context: SIDECAR_INBOUND listener: filterChain: filter: name: "envoy.filters.network.http_connection_manager" subFilter: name: "envoy.filters.http.ratelimit" patch: operation: INSERT_BEFORE # Adds the Envoy Rate Limit Filter in HTTP filter chain. value: name: envoy.set.hits.addend typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.set_filter_state.v3.Config on_request_headers: - object_key: envoy.ratelimit.hits_addend format_string: text_format_source: inline_string: "%REQ(:HITS)%" --- apiVersion: networking.istio.io/v1alpha3 kind: EnvoyFilter metadata: name: filter-ratelimit-svc spec: workloadSelector: labels: app: httpbin configPatches: - applyTo: VIRTUAL_HOST match: context: SIDECAR_INBOUND routeConfiguration: vhost: name: "" route: action: ANY patch: operation: MERGE # Applies the rate limit rules. value: rate_limits: - actions: # any actions in here - request_headers: header_name: "x-rate-limit-please" descriptor_key: "ratelimitheader" skip_if_absent: true - request_headers: header_name: ":path" descriptor_key: "PATH"