-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: prevent policies targeting non-TLS listeners on the same port fr…
…om conflicting (#2786) * * Validate that multiple policies that affect listener configuration don't map to the same listener filter chain. * Change the XDS listener generation so that instead of defaultFilterChain for non-TLS routes, a filterChain with a destinationPort matcher is used. This allows multiple policies attached to non-TLS listeners that differ on the destination port to provide different policies without conflicting. Signed-off-by: Lior Okman <[email protected]> * Make hostname based routing work again for non-TLS listeners Signed-off-by: Lior Okman <[email protected]> * Fixed testdata for egctl Signed-off-by: Lior Okman <[email protected]> * Make the linter happy Signed-off-by: Lior Okman <[email protected]> * Added a unit-test Signed-off-by: Lior Okman <[email protected]> * Make the linter happy Signed-off-by: Lior Okman <[email protected]> * Update an e2e test with the new filterChain patch Signed-off-by: Lior Okman <[email protected]> * Revert changing the XDS translation, since a new listener is created anyways for each port. Signed-off-by: Lior Okman <[email protected]> * Also revert the xds change in the e2e test. Signed-off-by: Lior Okman <[email protected]> * Don't need to go over the full XDSIR map - just the current gateway. Signed-off-by: Lior Okman <[email protected]> * Refactored to separate the validation and the translation. Renamed the helper method to a more generic name. Signed-off-by: Lior Okman <[email protected]> --------- Signed-off-by: Lior Okman <[email protected]> Co-authored-by: Guy Daich <[email protected]>
- Loading branch information
Showing
5 changed files
with
547 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
119 changes: 119 additions & 0 deletions
119
internal/gatewayapi/testdata/conflicting-policies.in.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
envoyproxy: | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: EnvoyProxy | ||
metadata: | ||
name: test | ||
namespace: envoy-gateway-system | ||
spec: | ||
mergeGateways: true | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: gateway-1 | ||
namespace: default | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- hostname: "*.192.168.0.15.nip.io" | ||
name: http | ||
protocol: HTTP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
name: mfqjpuycbgjrtdww | ||
namespace: default | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- hostname: qccbahgo.qccbahgo | ||
name: http | ||
port: 80 | ||
protocol: HTTP | ||
httpRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: bdkzlmibsivuiqav | ||
namespace: default | ||
spec: | ||
hostnames: | ||
- ntjxuedx.192.168.0.15.nip.io | ||
parentRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: default | ||
sectionName: http | ||
rules: | ||
- backendRefs: | ||
- name: service-1 | ||
port: 8080 | ||
matches: | ||
- path: | ||
type: PathPrefix | ||
value: / | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: mfqjpuycbgjrtdww | ||
namespace: default | ||
spec: | ||
hostnames: | ||
- qccbahgo.qccbahgo | ||
parentRefs: | ||
- group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: mfqjpuycbgjrtdww | ||
namespace: default | ||
sectionName: http | ||
rules: | ||
- backendRefs: | ||
- name: service-1 | ||
port: 8080 | ||
matches: | ||
- path: | ||
type: PathPrefix | ||
value: / | ||
securityPolicies: | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: SecurityPolicy | ||
metadata: | ||
name: cors-example | ||
namespace: default | ||
spec: | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: mfqjpuycbgjrtdww | ||
cors: | ||
allowOrigins: | ||
- "http://*.foo.com" | ||
allowMethods: | ||
- PUT | ||
- GET | ||
- POST | ||
- DELETE | ||
- PATCH | ||
- OPTIONS | ||
maxAge: 600s | ||
allowCredentials: true | ||
clientTrafficPolicies: | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: ClientTrafficPolicy | ||
metadata: | ||
namespace: default | ||
name: target-gateway | ||
spec: | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: mfqjpuycbgjrtdww | ||
namespace: default | ||
timeout: | ||
http: | ||
requestReceivedTimeout: "5s" |
Oops, something went wrong.