Envoy Filter
NOTE 1: Since this is break glass configuration, there will not be any backward compatibility across different Istio releases. In other words, this configuration is subject to change based on internal implementation of Istio networking subsystem.
NOTE 2: The envoy configuration provided through this mechanism should be carefully monitored across Istio proxy version upgrades, to ensure that deprecated fields are removed and replaced appropriately.
NOTE 3: When multiple EnvoyFilters are bound to the same workload in a given namespace, all patches will be processed sequentially in order of creation time. The behavior is undefined if multiple EnvoyFilter configurations conflict with each other.
NOTE 4: *_To apply an EnvoyFilter resource to all workloads (sidecars and gateways) in the system, define the resource in the config root namespace, without a workloadSelector.
The example below declares a global default EnvoyFilter resource in the root namespace called istio-config
, that adds a custom protocol filter on all sidecars in the system, for outbound port 9307. The filter should be added before the terminating tcp_proxy filter to take effect. In addition, it sets a 30s idle timeout for all HTTP connections in both gateays and sidecars.
The following example enables Envoy’s Lua filter for all inbound HTTP calls arriving at service port 8080 of the reviews service pod with labels “app: reviews”, in the bookinfo namespace. The lua filter calls out to an external service internal.org.net:8888 that requires a special cluster definition in envoy. The cluster is also added to the sidecar as part of this configuration.
The following example overwrites certain fields (HTTP idle timeout and X-Forward-For trusted hops) in the HTTP connection manager in a listener on the ingress gateway in istio-system namespace for the SNI host app.example.com:
EnvoyFilter provides a mechanism to customize the Envoy configuration generated by Istio Pilot.
EnvoyFilter.ApplyTo
ApplyTo specifies where in the Envoy configuration, the given patch should be applied.
Name | Description |
---|---|
INVALID | |
LISTENER | Applies the patch to the listener. |
FILTER_CHAIN | Applies the patch to the filter chain. |
NETWORK_FILTER | Applies the patch to the network filter chain, to modify an existing filter or add a new filter. |
HTTP_FILTER | Applies the patch to the HTTP filter chain in the http connection manager, to modify an existing filter or add a new filter. |
ROUTE_CONFIGURATION | Applies the patch to the Route configuration (rds output) inside a HTTP connection manager. This does not apply to the virtual host. Currently, only MERGE operation is allowed on the route configuration objects. |
VIRTUAL_HOST | Applies the patch to a virtual host inside a route configuration. |
HTTP_ROUTE | Applies the patch to a route object inside the matched virtual host in a route configuration. Currently, only MERGE operation is allowed on the route objects. |
CLUSTER | Applies the patch to a cluster in a CDS output. Also used to add new clusters. |
EnvoyFilter.ClusterMatch
Conditions specified in ClusterMatch must be met for the patch to be applied to a cluster.
Field | Type | Description | Required |
---|---|---|---|
portNumber | uint32 | The service port for which this cluster was generated. If omitted, applies to clusters for any port. | No |
service | string | The fully qualified service name for this cluster. If omitted, applies to clusters for any service. For services defined through service entries, the service name is same as the hosts defined in the service entry. | No |
subset | string | The subset associated with the service. If omitted, applies to clusters for any subset of a service. | No |
name | string | The exact name of the cluster to match. To match a specific cluster by name, such as the internally generated “Passthrough” cluster, leave all fields in clusterMatch empty, except the name. | No |
EnvoyFilter.DeprecatedListenerMatch.ListenerProtocol
Name | Description |
---|---|
ALL | All protocols |
HTTP | HTTP or HTTPS (with termination) / HTTP2/gRPC |
TCP | Any non-HTTP listener |
EnvoyFilter.DeprecatedListenerMatch.ListenerType
Name | Description |
---|---|
ANY | All listeners |
SIDECAR_INBOUND | Inbound listener in sidecar |
SIDECAR_OUTBOUND | Outbound listener in sidecar |
GATEWAY | Gateway listener |
EnvoyFilter.EnvoyConfigObjectMatch
One or more match conditions to be met before a patch is applied to the generated configuration for a given proxy.
Field | Type | Description | Required |
---|---|---|---|
context | PatchContext | No | |
proxy |
| Match on properties associated with a proxy. | No |
listener | ListenerMatch (oneof) | Match on envoy listener attributes. | Yes |
routeConfiguration |
| Match on envoy HTTP route configuration attributes. | Yes |
cluster | Match on envoy cluster attributes. | Yes |
EnvoyFilter.EnvoyConfigObjectPatch
Changes to be made to various envoy config objects.
Field | Type | Description | Required |
---|---|---|---|
applyTo |
| Specifies where in the Envoy configuration, the patch should be applied. The match is expected to select the appropriate object based on applyTo. For example, an applyTo with HTTPFILTER is expected to have a match condition on the listeners, with a network filter selection on envoy.httpconnection_manager and a sub filter selection on the HTTP filter relative to which the insertion should be performed. Similarly, an applyTo on CLUSTER should have a match (if provided) on the cluster and not on a listener. | No |
match | EnvoyConfigObjectMatch | Match on listener/route configuration/cluster. | No |
patch |
| The patch to apply along with the operation. | No |
EnvoyFilter.InsertPosition.Index
Index/position in the filter chain.
Name | Description |
---|---|
FIRST | Insert first |
LAST | Insert last |
BEFORE | Insert before the named filter. |
AFTER | Insert after the named filter. |
EnvoyFilter.ListenerMatch
Conditions specified in a listener match must be met for the patch to be applied to a specific listener across all filter chains, or a specific filter chain inside the listener.
Field | Type | Description | Required |
---|---|---|---|
portNumber | uint32 | The service port/gateway port to which traffic is being sent/received. If not specified, matches all listeners. Even though inbound listeners are generated for the instance/pod ports, only service ports should be used to match listeners. | No |
filterChain | FilterChainMatch | Match a specific filter chain in a listener. If specified, the patch will be applied to the filter chain (and a specific filter if specified) and not to other filter chains in the listener. | No |
name | string | Match a specific listener by its name. The listeners generated by Pilot are typically named as IP:Port. | No |
EnvoyFilter.ListenerMatch.FilterChainMatch
For listeners with multiple filter chains (e.g., inbound listeners on sidecars with permissive mTLS, gateway listeners with multiple SNI matches), the filter chain match can be used to select a specific filter chain to patch.
Field | Type | Description | Required |
---|---|---|---|
name | string | The name assigned to the filter chain. | No |
sni | string | The SNI value used by a filter chain’s match condition. This condition will evaluate to false if the filter chain has no sni match. | No |
transportProtocol | string | Applies only to SIDECARINBOUND context. If non-empty, a transport protocol to consider when determining a filter chain match. This value will be compared against the transport protocol of a new connection, when it’s detected by the tlsinspector listener filter. Accepted values include:
| No |
applicationProtocols | string | Applies only to sidecars. If non-empty, a comma separated set of application protocols to consider when determining a filter chain match. This value will be compared against the application protocols of a new connection, when it’s detected by one of the listener filters such as the http_inspector. Accepted values include: h2,http/1.1,http/1.0 | No |
filter | FilterMatch | The name of a specific filter to apply the patch to. Set this to envoy.httpconnectionmanager to add a filter or apply a patch to the HTTP connection manager. | No |
EnvoyFilter.ListenerMatch.FilterMatch
Conditions to match a specific filter within a filter chain.
Field | Type | Description | Required |
---|---|---|---|
name | string | The filter name to match on. | No |
subFilter | SubFilterMatch | The next level filter within this filter to match upon. Typically used for HTTP Connection Manager filters and Thrift filters. | No |
EnvoyFilter.ListenerMatch.SubFilterMatch
Conditions to match a specific filter within another filter. This field is typically useful to match a HTTP filter inside the envoy.httpconnectionmanager network filter. This could also be applicable for thrift filters.
Field | Type | Description | Required |
---|---|---|---|
name | string | No |
EnvoyFilter.Patch
Patch specifies how the selected object should be modified.
Field | Type | Description | Required |
---|---|---|---|
operation | Determines how the patch should be applied. | No | |
value |
| The JSON config of the object being patched. This will be merged using json merge semantics with the existing proto in the path. | No |
Operation denotes how the patch should be applied to the selected configuration.
EnvoyFilter.PatchContext
PatchContext selects a class of configurations based on the traffic flow direction and workload type.
Name | Description |
---|---|
ANY | All listeners/routes/clusters in both sidecars and gateways. |
SIDECAR_INBOUND | Inbound listener/route/cluster in sidecar. |
SIDECAR_OUTBOUND | Outbound listener/route/cluster in sidecar. |
GATEWAY | Gateway listener/route/cluster. |
EnvoyFilter.ProxyMatch
One or more properties of the proxy to match on.
Field | Type | Description | Required |
---|---|---|---|
proxyVersion | string | A regular expression in golang regex format (RE2) that can be used to select proxies using a specific version of istio proxy. The Istio version for a given proxy is obtained from the node metadata field ISTIOVERSION supplied by the proxy when connecting to Pilot. This value is embedded as an environment variable (ISTIOMETAISTIOVERSION) in the Istio proxy docker image. Custom proxy implementations should provide this metadata variable to take advantage of the Istio version check option. | No |
metadata | map<string, string> | Match on the node metadata supplied by a proxy when connecting to Istio Pilot. Note that while Envoy’s node metadata is of type Struct, only string key-value pairs are processed by Pilot. All keys specified in the metadata must match with exact values. The match will fail if any of the specified keys are absent or the values fail to match. | No |
EnvoyFilter.RouteConfigurationMatch
Conditions specified in RouteConfigurationMatch must be met for the patch to be applied to a route configuration object or a specific virtual host within the route configuration.
Field | Type | Description | Required |
---|---|---|---|
portNumber | uint32 | The service port number or gateway server port number for which this route configuration was generated. If omitted, applies to route configurations for all ports. | No |
portName | string | Applicable only for GATEWAY context. The gateway server port name for which this route configuration was generated. | No |
gateway | string | The Istio gateway config’s namespace/name for which this route configuration was generated. Applies only if the context is GATEWAY. Should be in the namespace/name format. Use this field in conjunction with the portNumber and portName to accurately select the Envoy route configuration for a specific HTTPS server within a gateway config object. | No |
vhost |
| Match a specific virtual host in a route configuration and apply the patch to the virtual host. | No |
name | string | Route configuration name to match on. Can be used to match a specific route configuration by name, such as the internally generated “http_proxy” route configuration for all sidecars. | No |
EnvoyFilter.RouteConfigurationMatch.RouteMatch
Match a specific route inside a virtual host in a route configuration.
Field | Type | Description | Required |
---|---|---|---|
name | string | The Route objects generated by default are named as “default”. Route objects generated using a virtual service will carry the name used in the virtual service’s HTTP routes. | No |
action |
| Match a route with specific action type. | No |
EnvoyFilter.RouteConfigurationMatch.RouteMatch.Action
Action refers to the route action taken by Envoy when a http route matches.
Name | Description |
---|---|
ANY | All three route actions |
ROUTE | Route traffic to a cluster / weighted clusters. |
REDIRECT | Redirect request. |
DIRECT_RESPONSE | directly respond to a request with specific payload. |
EnvoyFilter.RouteConfigurationMatch.VirtualHostMatch
Match a specific virtual host inside a route configuration.
Field | Type | Description | Required |
---|---|---|---|
name | string | No | |
route | RouteMatch | Match a specific route within the virtual host. | No |