istio.io/istio@v0.0.0-20240520182934-d79c90f27776/pkg/config/analysis/analyzers/testdata/envoy-filter-replace-operation.yaml (about) 1 # If the patch operation is REPLACE but priority is set, then the analyzer will not do anything 2 # If the patch operation is REPLACE but the applyTo is not HTTP_FILTER or NETWORK_FILTER, then an error will occur 3 apiVersion: networking.istio.io/v1alpha3 4 kind: EnvoyFilter 5 metadata: 6 name: test-replace-1 7 namespace: bookinfo 8 spec: 9 workloadSelector: 10 labels: 11 app: reviews1 12 priority: 10 13 configPatches: 14 - applyTo: CLUSTER 15 match: 16 context: SIDECAR_OUTBOUND 17 patch: 18 operation: REPLACE 19 value: # cluster specification 20 name: "lua_cluster" 21 type: STRICT_DNS 22 connect_timeout: 0.5s 23 lb_policy: ROUND_ROBIN 24 load_assignment: 25 cluster_name: lua_cluster 26 endpoints: 27 - lb_endpoints: 28 - endpoint: 29 address: 30 socket_address: 31 protocol: TCP 32 address: "internal.org.net" 33 port_value: 8888 34 --- 35 apiVersion: networking.istio.io/v1alpha3 36 kind: EnvoyFilter 37 metadata: 38 name: test-replace-2 39 namespace: bookinfo 40 spec: 41 workloadSelector: 42 labels: 43 app: reviews2 44 priority: 10 45 configPatches: 46 # The first patch adds the Lua filter to the listener/http connection manager 47 - applyTo: HTTP_FILTER 48 match: 49 context: SIDECAR_INBOUND 50 listener: 51 portNumber: 8080 52 filterChain: 53 filter: 54 name: "envoy.filters.network.http_connection_manager" 55 subFilter: 56 name: "envoy.filters.http.router" 57 patch: 58 operation: REPLACE 59 value: # Lua filter specification 60 name: envoy.lua 61 typed_config: 62 "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua" 63 inlineCode: | 64 function envoy_on_request(request_handle) 65 -- Make an HTTP call to an upstream host with the following headers, body, and timeout. 66 local headers, body = request_handle:httpCall( 67 "lua_cluster", 68 { 69 [":method"] = "POST", 70 [":path"] = "/acl", 71 [":authority"] = "internal.org.net" 72 }, 73 "authorize call", 74 5000) 75 end 76 77 --- 78 apiVersion: networking.istio.io/v1alpha3 79 kind: EnvoyFilter 80 metadata: 81 name: test-replace-3 82 namespace: bookinfo 83 spec: 84 workloadSelector: 85 labels: 86 app: reviews4 87 configPatches: 88 # The first patch adds the Lua filter to the listener/http connection manager 89 - applyTo: HTTP_FILTER 90 match: 91 context: SIDECAR_OUTBOUND 92 proxy: 93 proxyVersion: '^1\.11.*' 94 listener: 95 portNumber: 8080 96 filterChain: 97 filter: 98 name: "envoy.filters.network.http_connection_manager" 99 subFilter: 100 name: "envoy.filters.http.router" 101 patch: 102 operation: REPLACE 103 value: # Lua filter specification 104 name: envoy.lua 105 typed_config: 106 "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua" 107 inlineCode: | 108 function envoy_on_request(request_handle) 109 -- Make an HTTP call to an upstream host with the following headers, body, and timeout. 110 local headers, body = request_handle:httpCall( 111 "lua_cluster", 112 { 113 [":method"] = "POST", 114 [":path"] = "/acl", 115 [":authority"] = "internal.org.net" 116 }, 117 "authorize call", 118 5000) 119 end 120 - applyTo: HTTP_FILTER 121 match: 122 context: SIDECAR_INBOUND 123 patch: 124 operation: REPLACE 125 value: #Lua filter specification 126 name: envoy.lua 127 typed_config: 128 "@type": "type.googleapis.com/envoy.extensions.filters.http.lua.v3.Lua" 129 inlineCode: | 130 function envoy_on_request(request_handle) 131 -- Make an HTTP call to an upstream host with the following headers, body, and timeout. 132 local headers, body = request_handle:httpCall( 133 "lua_cluster", 134 { 135 [":method"] = "POST", 136 [":path"] = "/acl", 137 [":authority"] = "internal.org.net" 138 }, 139 "authorize call", 140 5000) 141 end 142 # The third patch adds the cluster that is referenced by the lua code 143 # cds match is omitted as a new cluster is being added 144 - applyTo: NETWORK_FILTER 145 match: 146 context: SIDECAR_OUTBOUND 147 patch: 148 operation: REPLACE 149 value: # cluster specification 150 name: "lua_cluster" 151 type: STRICT_DNS 152 connect_timeout: 0.5s 153 lb_policy: ROUND_ROBIN 154 load_assignment: 155 cluster_name: lua_cluster 156 endpoints: 157 - lb_endpoints: 158 - endpoint: 159 address: 160 socket_address: 161 protocol: TCP 162 address: "internal.org.net" 163 port_value: 8888