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