-
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: AccessLog support CEL Filter (#3688)
* translator Signed-off-by: zirain <zirain2009@gmail.com> * gatewayapi Signed-off-by: zirain <zirain2009@gmail.com> * filename Signed-off-by: zirain <zirain2009@gmail.com> * share CEL Env Signed-off-by: zirain <zirain2009@gmail.com> --------- Signed-off-by: zirain <zirain2009@gmail.com>
- Loading branch information
Showing
20 changed files
with
1,246 additions
and
4 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
90 changes: 90 additions & 0 deletions
90
internal/gatewayapi/testdata/envoyproxy-accesslog-cel-with-invalid.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,90 @@ | ||
envoyProxyForGatewayClass: | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: EnvoyProxy | ||
metadata: | ||
namespace: envoy-gateway-system | ||
name: test | ||
spec: | ||
telemetry: | ||
accessLog: | ||
settings: | ||
- matches: | ||
- "response.code >= 400" | ||
- ")++++" # invalid CEL expression will be ignored | ||
Check warning on line 13 in internal/gatewayapi/testdata/envoyproxy-accesslog-cel-with-invalid.in.yaml GitHub Actions / lint
|
||
format: | ||
type: Text | ||
text: | | ||
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n | ||
sinks: | ||
- type: File | ||
file: | ||
path: /dev/stdout | ||
- type: OpenTelemetry | ||
openTelemetry: | ||
host: otel-collector.monitoring.svc.cluster.local | ||
port: 4317 | ||
resources: | ||
k8s.cluster.name: "cluster-1" | ||
provider: | ||
type: Kubernetes | ||
kubernetes: | ||
envoyService: | ||
type: LoadBalancer | ||
envoyDeployment: | ||
replicas: 2 | ||
container: | ||
env: | ||
- name: env_a | ||
value: env_a_value | ||
- name: env_b | ||
value: env_b_name | ||
image: "envoyproxy/envoy:distroless-dev" | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 512Mi | ||
securityContext: | ||
runAsUser: 2000 | ||
allowPrivilegeEscalation: false | ||
pod: | ||
annotations: | ||
key1: val1 | ||
key2: val2 | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: cloud.google.com/gke-nodepool | ||
operator: In | ||
values: | ||
- router-node | ||
tolerations: | ||
- effect: NoSchedule | ||
key: node-type | ||
operator: Exists | ||
value: "router" | ||
securityContext: | ||
runAsUser: 1000 | ||
runAsGroup: 3000 | ||
fsGroup: 2000 | ||
fsGroupChangePolicy: "OnRootMismatch" | ||
volumes: | ||
- name: certs | ||
secret: | ||
secretName: envoy-cert | ||
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 | ||
allowedRoutes: | ||
namespaces: | ||
from: Same |
153 changes: 153 additions & 0 deletions
153
internal/gatewayapi/testdata/envoyproxy-accesslog-cel-with-invalid.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,153 @@ | ||
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: Same | ||
name: http | ||
port: 80 | ||
protocol: HTTP | ||
status: | ||
conditions: | ||
- lastTransitionTime: null | ||
message: 'Invalid access log backendRefs: invalid CEL expression: )++++' | ||
reason: Invalid | ||
status: "False" | ||
type: ListenersNotValid | ||
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: http | ||
supportedKinds: | ||
- group: gateway.networking.k8s.io | ||
kind: HTTPRoute | ||
- group: gateway.networking.k8s.io | ||
kind: GRPCRoute | ||
infraIR: | ||
envoy-gateway/gateway-1: | ||
proxy: | ||
config: | ||
apiVersion: gateway.envoyproxy.io/v1alpha1 | ||
kind: EnvoyProxy | ||
metadata: | ||
creationTimestamp: null | ||
name: test | ||
namespace: envoy-gateway-system | ||
spec: | ||
logging: {} | ||
provider: | ||
kubernetes: | ||
envoyDeployment: | ||
container: | ||
env: | ||
- name: env_a | ||
value: env_a_value | ||
- name: env_b | ||
value: env_b_name | ||
image: envoyproxy/envoy:distroless-dev | ||
resources: | ||
requests: | ||
cpu: 100m | ||
memory: 512Mi | ||
securityContext: | ||
allowPrivilegeEscalation: false | ||
runAsUser: 2000 | ||
pod: | ||
affinity: | ||
nodeAffinity: | ||
requiredDuringSchedulingIgnoredDuringExecution: | ||
nodeSelectorTerms: | ||
- matchExpressions: | ||
- key: cloud.google.com/gke-nodepool | ||
operator: In | ||
values: | ||
- router-node | ||
annotations: | ||
key1: val1 | ||
key2: val2 | ||
securityContext: | ||
fsGroup: 2000 | ||
fsGroupChangePolicy: OnRootMismatch | ||
runAsGroup: 3000 | ||
runAsUser: 1000 | ||
tolerations: | ||
- effect: NoSchedule | ||
key: node-type | ||
operator: Exists | ||
value: router | ||
volumes: | ||
- name: certs | ||
secret: | ||
secretName: envoy-cert | ||
replicas: 2 | ||
envoyService: | ||
type: LoadBalancer | ||
type: Kubernetes | ||
telemetry: | ||
accessLog: | ||
settings: | ||
- format: | ||
text: | | ||
[%START_TIME%] "%REQ(:METHOD)% %PROTOCOL%" %RESPONSE_CODE% %RESPONSE_FLAGS% %BYTES_RECEIVED% %BYTES_SENT% %DURATION% %RESP(X-ENVOY-UPSTREAM-SERVICE-TIME)% "%REQ(X-FORWARDED-FOR)%" "%REQ(USER-AGENT)%" "%REQ(X-REQUEST-ID)%" "%REQ(:AUTHORITY)%" "%UPSTREAM_HOST%"\n | ||
type: Text | ||
matches: | ||
- response.code >= 400 | ||
- )++++ | ||
sinks: | ||
- file: | ||
path: /dev/stdout | ||
type: File | ||
- openTelemetry: | ||
host: otel-collector.monitoring.svc.cluster.local | ||
port: 4317 | ||
resources: | ||
k8s.cluster.name: cluster-1 | ||
type: OpenTelemetry | ||
status: {} | ||
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: | ||
http: | ||
- address: 0.0.0.0 | ||
hostnames: | ||
- '*' | ||
isHTTP2: false | ||
name: envoy-gateway/gateway-1/http | ||
path: | ||
escapedSlashesAction: UnescapeAndRedirect | ||
mergeSlashes: true | ||
port: 10080 |
Oops, something went wrong.