Kubernetes Envoy
- English
- 日本語
この例では、Next-Gen WAF エージェントが Docker のサイドカーで実行され、アプリケーションにデプロイされた Envoy プロキシと直接通信します。
Next-Gen WAF エージェントを Envoy プロキシに統合する
Next-Gen WAF エージェントは、外部処理 (ext_proc) HTTP フィルターを介して Envoy プロキシと統合できます。このフィルターは、gRPC を通じて sigsci-agent と通信します。
通常の RPC リスナーではなく、Envoy gRPC リスナーで実行されるように sigsci-agent を設定します。これを行うには、envoy-grpc-address エージェント設定オプションを設定します。設定すると、デフォルトの RPC リスナーではなく、Envoy gRPC リスナーが起動します。
sigsci-agent 設定ファイルの設定値を次のように設定します。
envoy-grpc-address = "0.0.0.0:8000"または、以下のように sigsci-agent 環境で設定値を指定してください
SIGSCI_ENVOY_GRPC_ADDRESS=0.0.0.0:8000TLSを有効にして sigsci-agent を設定することもできます。これを行うには、sigsci-agent 設定ファイルで証明書ファイルとキーファイルを設定してください:
envoy-grpc-cert = "/path/to/cert.pem"envoy-grpc-key = "/path/to/key.pem"あるいは、以下のように sigsci-agent 環境に設定してください
SIGSCI_ENVOY_GRPC_CERT=/path/to/cert.pemSIGSCI_ENVOY_GRPC_KEY=/path/to/key.pemEnvoy 設定
Envoy は、メインのハンドラーフィルターよりも前に外部処理 HTTP フィルター (envoy.filters.http.ext_proc) で設定する必要があります。データを処理するために、以下に示す例のように sigsci-agent-grpc クラスタを指すものを使用します。
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.Routerサンプルのデプロイ
サンプルデプロイ設定セクションには、完全な Envoy プロキシデプロイ設定が含まれています。これは、自分のデプロイの出発点として利用できます。サンプル設定を動作させるためには、次の手順を完了させます。
以下のコマンドを実行して、ワークスペースのエージェントキーを更新してください。
$ kubectl create secret generic sigsci.test \--from-literal=accesskeyid=<access-key-id> \--from-literal=secretaccesskey=<secret-access-key><access-key-id>と<secret-access-key>は必ずエージェントキーに置き換えてください。サンプルデプロイ設定を
envoy-deployment.yamlとして保存してください。次のコマンドを実行して
envoy-deployment.yamlをデプロイします。$ kubectl apply -f envoy-deployment.yaml(任意) ポートフォワーディングを設定し、次のコマンドを実行してローカルでデプロイをテストします。
$ kubectl port-forward svc/envoy 10000:10000
サンプルのデプロイ設定
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