-
Notifications
You must be signed in to change notification settings - Fork 360
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(translator): Support extension server hooks for TCP and UDP list…
…eners in addition to HTTP listeners. (#3522) * Support extension server hooks for TCP and UDP listeners in addition to HTTP listeners. Signed-off-by: Lior Okman <lior.okman@sap.com> * Extension policies should be gathered based on the xds listener name Signed-off-by: Lior Okman <lior.okman@sap.com> * Cleanly separate the extension hook server listener hook logic from the translation logic. Signed-off-by: Lior Okman <lior.okman@sap.com> * Update the test with the listener name. Signed-off-by: Lior Okman <lior.okman@sap.com> * Final touches after the rebase to align with the linter. Signed-off-by: Lior Okman <lior.okman@sap.com> * Removed an unused function. Signed-off-by: Lior Okman <lior.okman@sap.com>
- Loading branch information
Showing
20 changed files
with
1,109 additions
and
137 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
45 changes: 45 additions & 0 deletions
45
internal/gatewayapi/testdata/extensions/extensionpolicy-tcp-listener.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,45 @@ | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-1 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: tcp1 | ||
protocol: TCP | ||
port: 80 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
- name: tcp2 | ||
protocol: TCP | ||
port: 81 | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
extensionServerPolicies: | ||
- apiVersion: foo.example.io/v1alpha1 | ||
kind: Bar | ||
metadata: | ||
name: test1 | ||
namespace: envoy-gateway | ||
spec: | ||
targetRef: | ||
kind: Gateway | ||
group: gateway.networking.k8s.io | ||
name: gateway-1 | ||
data: "attached to all listeners" | ||
- apiVersion: foo.example.io/v1alpha1 | ||
kind: Bar | ||
metadata: | ||
name: test2 | ||
namespace: envoy-gateway | ||
spec: | ||
targetRef: | ||
kind: Gateway | ||
group: gateway.networking.k8s.io | ||
name: gateway-1 | ||
sectionName: tcp1 | ||
data: "attached only to listener on port 80" |
236 changes: 236 additions & 0 deletions
236
internal/gatewayapi/testdata/extensions/extensionpolicy-tcp-listener.out.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,236 @@ | ||
extensionServerPolicies: | ||
- apiVersion: foo.example.io/v1alpha1 | ||
kind: Bar | ||
metadata: | ||
name: test1 | ||
namespace: envoy-gateway | ||
spec: | ||
data: attached to all listeners | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
status: | ||
ancestors: | ||
- ancestorRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Policy has been accepted. | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
- apiVersion: foo.example.io/v1alpha1 | ||
kind: Bar | ||
metadata: | ||
name: test2 | ||
namespace: envoy-gateway | ||
spec: | ||
data: attached only to listener on port 80 | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
sectionName: tcp1 | ||
status: | ||
ancestors: | ||
- ancestorRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: tcp1 | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Policy has been accepted. | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
creationTimestamp: null | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- allowedRoutes: | ||
namespaces: | ||
from: All | ||
name: tcp1 | ||
port: 80 | ||
protocol: TCP | ||
- allowedRoutes: | ||
namespaces: | ||
from: All | ||
name: tcp2 | ||
port: 81 | ||
protocol: TCP | ||
status: | ||
listeners: | ||
- attachedRoutes: 0 | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Sending translated listener configuration to the data plane | ||
reason: Programmed | ||
status: "True" | ||
type: Programmed | ||
- lastTransitionTime: null | ||
message: Listener has been successfully translated | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
- lastTransitionTime: null | ||
message: Listener references have been resolved | ||
reason: ResolvedRefs | ||
status: "True" | ||
type: ResolvedRefs | ||
name: tcp1 | ||
supportedKinds: | ||
- group: gateway.networking.k8s.io | ||
kind: TCPRoute | ||
- attachedRoutes: 0 | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Sending translated listener configuration to the data plane | ||
reason: Programmed | ||
status: "True" | ||
type: Programmed | ||
- lastTransitionTime: null | ||
message: Listener has been successfully translated | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
- lastTransitionTime: null | ||
message: Listener references have been resolved | ||
reason: ResolvedRefs | ||
status: "True" | ||
type: ResolvedRefs | ||
name: tcp2 | ||
supportedKinds: | ||
- group: gateway.networking.k8s.io | ||
kind: TCPRoute | ||
infraIR: | ||
envoy-gateway/gateway-1: | ||
proxy: | ||
listeners: | ||
- address: null | ||
name: envoy-gateway/gateway-1/tcp1 | ||
ports: | ||
- containerPort: 10080 | ||
name: tcp-80 | ||
protocol: TCP | ||
servicePort: 80 | ||
- address: null | ||
name: envoy-gateway/gateway-1/tcp2 | ||
ports: | ||
- containerPort: 10081 | ||
name: tcp-81 | ||
protocol: TCP | ||
servicePort: 81 | ||
metadata: | ||
labels: | ||
gateway.envoyproxy.io/owning-gateway-name: gateway-1 | ||
gateway.envoyproxy.io/owning-gateway-namespace: envoy-gateway | ||
name: envoy-gateway/gateway-1 | ||
xdsIR: | ||
envoy-gateway/gateway-1: | ||
accessLog: | ||
text: | ||
- path: /dev/stdout | ||
tcp: | ||
- address: 0.0.0.0 | ||
extensionRefs: | ||
- object: | ||
apiVersion: foo.example.io/v1alpha1 | ||
kind: Bar | ||
metadata: | ||
name: test1 | ||
namespace: envoy-gateway | ||
spec: | ||
data: attached to all listeners | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
status: | ||
ancestors: | ||
- ancestorRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Policy has been accepted. | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
- object: | ||
apiVersion: foo.example.io/v1alpha1 | ||
kind: Bar | ||
metadata: | ||
name: test2 | ||
namespace: envoy-gateway | ||
spec: | ||
data: attached only to listener on port 80 | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
sectionName: tcp1 | ||
status: | ||
ancestors: | ||
- ancestorRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: tcp1 | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Policy has been accepted. | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
name: envoy-gateway/gateway-1/tcp1 | ||
port: 10080 | ||
- address: 0.0.0.0 | ||
extensionRefs: | ||
- object: | ||
apiVersion: foo.example.io/v1alpha1 | ||
kind: Bar | ||
metadata: | ||
name: test1 | ||
namespace: envoy-gateway | ||
spec: | ||
data: attached to all listeners | ||
targetRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
status: | ||
ancestors: | ||
- ancestorRef: | ||
group: gateway.networking.k8s.io | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
conditions: | ||
- lastTransitionTime: null | ||
message: Policy has been accepted. | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
name: envoy-gateway/gateway-1/tcp2 | ||
port: 10081 |
Oops, something went wrong.