Kubernetes Envoy
- English
- 日本語
In this example, the Next-Gen WAF agent runs in a Docker sidecar and communicates directly with an Envoy proxy deployed on the application.
Integrating the Next-Gen WAF agent into an Envoy Proxy
You can deploy the Next-Gen WAF agent for integration with the Envoy Proxy via the External Processing (ext_proc) HTTP filter. This filter communicates with the sigsci-agent via gRPC.
Configure the sigsci-agent to run with an Envoy gRPC listener instead of the normal RPC listener. To do this, set the envoy-grpc-address agent configuration option. When set, the Envoy gRPC listener starts instead of the default RPC listener.
Set the configuration value in the sigsci-agent config file:
envoy-grpc-address = "0.0.0.0:8000"Alternatively, set the configuration value in the sigsci-agent environment:
SIGSCI_ENVOY_GRPC_ADDRESS=0.0.0.0:8000You can also configure the sigsci-agent with TLS enabled. To do this, set the certificate and key files in the sigsci-agent config file:
envoy-grpc-cert = "/path/to/cert.pem"envoy-grpc-key = "/path/to/key.pem"Alternatively, set them in the sigsci-agent environment:
SIGSCI_ENVOY_GRPC_CERT=/path/to/cert.pemSIGSCI_ENVOY_GRPC_KEY=/path/to/key.pemEnvoy configuration
Envoy must be configured with an External Processing HTTP filter (envoy.filters.http.ext_proc) before the main handler filter to process data, such as the one shown in the example below that points at the sigsci-agent-grpc cluster.
123456789101112131415161718192021222324252627282930http_filters:- name: envoy.filters.http.buffer typed_config: # Maximum request body bytes buffered and sent to the sigsci-agent "@type": type.googleapis.com/envoy.extensions.filters.http.buffer.v3.Buffer max_request_bytes: 1048576 # 1 MB body size limit- name: envoy.filters.http.ext_proc typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor grpc_service: envoy_grpc: cluster_name: sigsci-agent-grpc timeout: 0.2s failure_mode_allow: true message_timeout: 0.2s request_attributes: - "connection.tls_version" - "request.host" - "request.path" - "request.scheme" - "source.address" processing_mode: request_header_mode: SEND response_header_mode: SEND request_body_mode: BUFFERED response_body_mode: NONE request_trailer_mode: SKIP response_trailer_mode: SKIP- name: envoy.filters.http.router typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.RouterSample deployment
The Sample deployment configuration section contains a complete Envoy proxy deployment configuration, which you can use as a starting point for your own deployment. For the sample configuration to work, complete the following steps:
Update the agent keys for your workspace by running the following command:
$ kubectl create secret generic sigsci.test \--from-literal=accesskeyid=<access-key-id> \--from-literal=secretaccesskey=<secret-access-key>Be sure to replace
<access-key-id>and<secret-access-key>with your agent keys.Save the Sample deployment configuration as
envoy-deployment.yaml.Deploy
envoy-deployment.yamlby running the following command:$ kubectl apply -f envoy-deployment.yaml(Optional) Set up port forwarding and test the deployment locally by running the following command:
$ kubectl port-forward svc/envoy 10000:10000
Sample deployment configuration
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204# ConfigMap: Contains the Envoy configurationapiVersion: v1kind: ConfigMapmetadata: name: envoy-configdata: envoy.yaml: | node: id: proxy-node cluster: proxy-cluster static_resources: listeners: - name: listener_0 address: socket_address: address: 0.0.0.0 port_value: 10000 filter_chains: - filters: - name: envoy.filters.network.http_connection_manager typed_config: "@type": type.googleapis.com/envoy.extensions.filters.network.http_connection_manager.v3.HttpConnectionManager stat_prefix: ingress_http route_config: name: local_route virtual_hosts: - name: backend domains: ["*"] # CORS configuration at virtual host level cors: allow_origin_string_match: - prefix: "*" allow_methods: GET, PUT, DELETE, POST, OPTIONS allow_headers: keep-alive,user-agent,cache-control,content-type,content-transfer-encoding,custom-header-1,x-accept-content-transfer-encoding,x-accept-response-streaming,x-user-agent,x-grpc-web,grpc-timeout max_age: "1728000" expose_headers: custom-header-1,grpc-status,grpc-message routes: - match: prefix: "/" route: cluster: edge_cluster host_rewrite_literal: "http.edgecompute.app" http_filters: # CORS filter to handle cross-origin requests - name: envoy.filters.http.cors typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.cors.v3.Cors # External processor filter calls the NGWAF agent via gRPC - name: envoy.filters.http.ext_proc typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.ext_proc.v3.ExternalProcessor grpc_service: envoy_grpc: cluster_name: sigsci-agent-grpc timeout: 0.2s failure_mode_allow: true message_timeout: 0.2s # Request attributes sent to the external processor request_attributes: - "connection.tls_version" - "request.host" - "request.path" - "request.scheme" - "source.address" processing_mode: request_header_mode: SEND response_header_mode: SEND request_body_mode: BUFFERED response_body_mode: NONE request_trailer_mode: SKIP response_trailer_mode: SKIP # Router filter (must be last) - name: envoy.filters.http.router typed_config: "@type": type.googleapis.com/envoy.extensions.filters.http.router.v3.Router clusters: # Cluster for forwarding requests to the upstream service - name: edge_cluster connect_timeout: 0.25s type: LOGICAL_DNS lb_policy: ROUND_ROBIN dns_lookup_family: V4_ONLY # Force IPv4-only DNS resolution load_assignment: cluster_name: edge_cluster endpoints: - lb_endpoints: - endpoint: address: socket_address: address: http.edgecompute.app port_value: 443 # TLS configuration for upstream HTTPS connection transport_socket: name: envoy.transport_sockets.tls typed_config: "@type": type.googleapis.com/envoy.extensions.transport_sockets.tls.v3.UpstreamTlsContext sni: "http.edgecompute.app" # Cluster used by the external processor filter to contact the NGWAF agent - name: sigsci-agent-grpc connect_timeout: 0.25s type: STATIC lb_policy: ROUND_ROBIN http2_protocol_options: {} # Enable HTTP/2 for gRPC communication load_assignment: cluster_name: sigsci-agent-grpc endpoints: - lb_endpoints: - endpoint: address: socket_address: # Both containers share the same network namespace address: 127.0.0.1 port_value: 9999
---
# Deployment: Combines the Envoy proxy and the Next‑Gen WAF Agent sidecarapiVersion: apps/v1kind: Deploymentmetadata: name: envoy-waf-deploymentspec: replicas: 1 selector: matchLabels: app: envoy-waf template: metadata: labels: app: envoy-waf spec: containers: # Envoy proxy container - name: envoy image: envoyproxy/envoy:v1.31-latest args: - "-c" - "/etc/envoy/envoy.yaml" - "-l" - "debug" # Change to "trace" for even more verbosity ports: - containerPort: 10000 volumeMounts: - name: envoy-config mountPath: /etc/envoy
# Next‑Gen WAF Agent container (sigsci-agent) - name: sigsci-agent image: signalsciences/sigsci-agent:latest imagePullPolicy: IfNotPresent env: - name: SIGSCI_ACCESSKEYID valueFrom: secretKeyRef: name: sigsci.test key: accesskeyid - name: SIGSCI_SECRETACCESSKEY valueFrom: secretKeyRef: name: sigsci.test key: secretaccesskey
# Configure agent for Envoy external processor integration - name: SIGSCI_ENVOY_EXTPROC_ENABLED value: "true" - name: SIGSCI_ENVOY_GRPC_ADDRESS value: "localhost:9999" - name: SIGSCI_DEBUG_LOG_VERBOSITY value: "3" - name: SIGSCI_SERVER_FLAVOR value: "envoy-sidecar"
ports: - containerPort: 9999 securityContext: # The sigsci-agent container should run with its root filesystem read only readOnlyRootFilesystem: true volumeMounts: - name: sigsci-tmp mountPath: /sigsci/tmp
volumes: - name: envoy-config configMap: name: envoy-config # Define a volume where sigsci-agent will write temp data and share the socket file, # which is required with the root filesystem is mounted read only - name: sigsci-tmp emptyDir: {}
---
# Service: Exposes the Envoy listener on port 10000apiVersion: v1kind: Servicemetadata: name: envoyspec: selector: app: envoy-waf ports: - protocol: TCP port: 10000 targetPort: 10000