EnvoyFilter CRD说明 配置示例二 为bookinfo命名空间下匹配标签app: reviews的工作负载下发自定义配置,在sidecar入站方向HttpConnectionManager中的最后一个Router插件之前插入lua插件,在收到请求后会执行lua代码调用一个外部授权服务;这个外部授权服务通过一个外部域名标识,也通过配置下发到数据面 apiVersion: networking.istio.io/v1alpha3 kind: EnvoyFilter metadata: name: reviewslua namespace: bookinfo spec: workloadSelector: labels: app: reviews configPatches: The first patch adds the lua filter to the listener/http connection manager applyTo: HTTPFILTER match: context: SIDECARINBOUND listener: portNumber: 8080 filterChain: filter: name: "envoy.filters.network.httpconnectionmanager" subFilter: name: "envoy.filters.http.router" patch: operation: INSERTBEFORE value: lua filter specification name: envoy.filters.http.lua typedconfig: "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua" defaultSourceCode: inlineString: function envoyonrequest(requesthandle) Make an HTTP call to an upstream host with the following headers, body, and timeout. local headers, body requesthandle:httpCall( "luacluster", { [":method"] "POST", [":path"] "/acl", [":authority"] "internal.org.net" }, "authorize call", 5000) end The second patch adds the cluster that is referenced by the lua code cds match is omitted as a new cluster is being added applyTo: CLUSTER match: context: SIDECAROUTBOUND patch: operation: ADD value: cluster specification name: "luacluster" type: STRICTDNS connecttimeout: 0.5s lbpolicy: ROUNDROBIN loadassignment: clustername: luacluster endpoints: lbendpoints: endpoint: address: socketaddress: protocol: TCP address: "internal.org.net" portvalue: 8888 配置示例三 为根命名空间下匹配istio: ingressgateway标签的网关下发自定义配置,当请求sni是app.example.com时给HttpConnectionManager配置HTTP空闲连接时间和XFF信任的跳数 apiVersion: networking.istio.io/v1alpha3 kind: EnvoyFilter metadata: name: hcmtweaks namespace: istiosystem spec: workloadSelector: labels: istio: ingressgateway configPatches: applyTo: NETWORKFILTER