forked from envoyproxy/gateway
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
direct response docs and tests (envoyproxy#4583)
* tests: direct response Signed-off-by: Arko Dasgupta <[email protected]> * unit tests Signed-off-by: Arko Dasgupta <[email protected]> * fix ns Signed-off-by: Arko Dasgupta <[email protected]> * docs for direct response Signed-off-by: Arko Dasgupta <[email protected]> * negative tests Signed-off-by: Arko Dasgupta <[email protected]>
- Loading branch information
Showing
7 changed files
with
749 additions
and
24 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
119 changes: 119 additions & 0 deletions
119
internal/gatewayapi/testdata/httproute-with-direct-response.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 @@ | ||
gateways: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: Gateway | ||
metadata: | ||
namespace: envoy-gateway | ||
name: gateway-1 | ||
spec: | ||
gatewayClassName: envoy-gateway-class | ||
listeners: | ||
- name: http | ||
protocol: HTTP | ||
port: 80 | ||
hostname: "*.envoyproxy.io" | ||
allowedRoutes: | ||
namespaces: | ||
from: All | ||
httpRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: direct-response | ||
namespace: default | ||
spec: | ||
parentRefs: | ||
- name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: http | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /inline | ||
filters: | ||
- type: ExtensionRef | ||
extensionRef: | ||
group: gateway.envoyproxy.io | ||
kind: HTTPRouteFilter | ||
name: direct-response-inline | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /value-ref | ||
filters: | ||
- type: ExtensionRef | ||
extensionRef: | ||
group: gateway.envoyproxy.io | ||
kind: HTTPRouteFilter | ||
name: direct-response-value-ref | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
name: direct-response-with-errors | ||
namespace: default | ||
spec: | ||
parentRefs: | ||
- name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: http | ||
rules: | ||
- matches: | ||
- path: | ||
type: PathPrefix | ||
value: /value-ref-not-found | ||
filters: | ||
- type: ExtensionRef | ||
extensionRef: | ||
group: gateway.envoyproxy.io | ||
kind: HTTPRouteFilter | ||
name: direct-response-value-ref-not-found | ||
configMaps: | ||
- apiVersion: v1 | ||
kind: ConfigMap | ||
metadata: | ||
name: value-ref-response | ||
namespace: default | ||
data: | ||
response.body: '{"error": "Internal Server Error"}' | ||
httpFilters: | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: HTTPRouteFilter | ||
metadata: | ||
name: direct-response-inline | ||
namespace: default | ||
spec: | ||
directResponse: | ||
contentType: text/plain | ||
body: | ||
type: Inline | ||
inline: "OK" | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: HTTPRouteFilter | ||
metadata: | ||
name: direct-response-value-ref-not-exit | ||
namespace: default | ||
spec: | ||
directResponse: | ||
contentType: application/json | ||
statusCode: 502 | ||
body: | ||
type: ValueRef | ||
valueRef: | ||
group: "" | ||
kind: ConfigMap | ||
name: value-ref-does-not-exist | ||
- apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: HTTPRouteFilter | ||
metadata: | ||
name: direct-response-value-ref | ||
namespace: default | ||
spec: | ||
directResponse: | ||
contentType: application/json | ||
statusCode: 502 | ||
body: | ||
type: ValueRef | ||
valueRef: | ||
group: "" | ||
kind: ConfigMap | ||
name: value-ref-response |
208 changes: 208 additions & 0 deletions
208
internal/gatewayapi/testdata/httproute-with-direct-response.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,208 @@ | ||
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 | ||
hostname: '*.envoyproxy.io' | ||
name: http | ||
port: 80 | ||
protocol: HTTP | ||
status: | ||
listeners: | ||
- attachedRoutes: 2 | ||
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: http | ||
supportedKinds: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
- group: gateway.networking.k8s.io | ||
kind: GRPCRoute | ||
httpRoutes: | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
creationTimestamp: null | ||
name: direct-response | ||
namespace: default | ||
spec: | ||
parentRefs: | ||
- name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: http | ||
rules: | ||
- filters: | ||
- extensionRef: | ||
group: gateway.envoyproxy.io | ||
kind: HTTPRouteFilter | ||
name: direct-response-inline | ||
type: ExtensionRef | ||
matches: | ||
- path: | ||
type: PathPrefix | ||
value: /inline | ||
- filters: | ||
- extensionRef: | ||
group: gateway.envoyproxy.io | ||
kind: HTTPRouteFilter | ||
name: direct-response-value-ref | ||
type: ExtensionRef | ||
matches: | ||
- path: | ||
type: PathPrefix | ||
value: /value-ref | ||
status: | ||
parents: | ||
- conditions: | ||
- lastTransitionTime: null | ||
message: Route is accepted | ||
reason: Accepted | ||
status: "True" | ||
type: Accepted | ||
- lastTransitionTime: null | ||
message: Resolved all the Object references for the Route | ||
reason: ResolvedRefs | ||
status: "True" | ||
type: ResolvedRefs | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
parentRef: | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: http | ||
- apiVersion: gateway.networking.k8s.io/v1 | ||
kind: HTTPRoute | ||
metadata: | ||
creationTimestamp: null | ||
name: direct-response-with-errors | ||
namespace: default | ||
spec: | ||
parentRefs: | ||
- name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: http | ||
rules: | ||
- filters: | ||
- extensionRef: | ||
group: gateway.envoyproxy.io | ||
kind: HTTPRouteFilter | ||
name: direct-response-value-ref-not-found | ||
type: ExtensionRef | ||
matches: | ||
- path: | ||
type: PathPrefix | ||
value: /value-ref-not-found | ||
status: | ||
parents: | ||
- conditions: | ||
- lastTransitionTime: null | ||
message: 'Unable to translate HTTPRouteFilter: default/direct-response-value-ref-not-found' | ||
reason: UnsupportedValue | ||
status: "False" | ||
type: Accepted | ||
- lastTransitionTime: null | ||
message: 'Unable to translate HTTPRouteFilter: default/direct-response-value-ref-not-found' | ||
reason: BackendNotFound | ||
status: "False" | ||
type: ResolvedRefs | ||
controllerName: gateway.envoyproxy.io/gatewayclass-controller | ||
parentRef: | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: http | ||
infraIR: | ||
envoy-gateway/gateway-1: | ||
proxy: | ||
listeners: | ||
- address: null | ||
name: envoy-gateway/gateway-1/http | ||
ports: | ||
- containerPort: 10080 | ||
name: http-80 | ||
protocol: HTTP | ||
servicePort: 80 | ||
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 | ||
http: | ||
- address: 0.0.0.0 | ||
hostnames: | ||
- '*.envoyproxy.io' | ||
isHTTP2: false | ||
metadata: | ||
kind: Gateway | ||
name: gateway-1 | ||
namespace: envoy-gateway | ||
sectionName: http | ||
name: envoy-gateway/gateway-1/http | ||
path: | ||
escapedSlashesAction: UnescapeAndRedirect | ||
mergeSlashes: true | ||
port: 10080 | ||
routes: | ||
- addResponseHeaders: | ||
- append: false | ||
name: Content-Type | ||
value: | ||
- application/json | ||
directResponse: | ||
body: '{"error": "Internal Server Error"}' | ||
statusCode: 502 | ||
hostname: '*.envoyproxy.io' | ||
isHTTP2: false | ||
metadata: | ||
kind: HTTPRoute | ||
name: direct-response | ||
namespace: default | ||
name: httproute/default/direct-response/rule/1/match/0/*_envoyproxy_io | ||
pathMatch: | ||
distinct: false | ||
name: "" | ||
prefix: /value-ref | ||
- addResponseHeaders: | ||
- append: false | ||
name: Content-Type | ||
value: | ||
- text/plain | ||
directResponse: | ||
body: OK | ||
statusCode: 200 | ||
hostname: '*.envoyproxy.io' | ||
isHTTP2: false | ||
metadata: | ||
kind: HTTPRoute | ||
name: direct-response | ||
namespace: default | ||
name: httproute/default/direct-response/rule/0/match/0/*_envoyproxy_io | ||
pathMatch: | ||
distinct: false | ||
name: "" | ||
prefix: /inline |
Oops, something went wrong.