diff --git a/infrastructure/networking/gateway/gatewayclass-config.yaml b/infrastructure/networking/gateway/gatewayclass-config.yaml new file mode 100644 index 0000000..58f7230 --- /dev/null +++ b/infrastructure/networking/gateway/gatewayclass-config.yaml @@ -0,0 +1,52 @@ +# Envoy access logging for every Gateway served by the Cilium GatewayClass. +# +# Finding F7 (2026-11-27 netsec audit): cilium-envoy emitted no request-level +# record at all, so the design's HTTP attack-shape rules (ยง4d: traversal, +# `union select`, `%00`, .env/.git probes, high-rate 401/403 per client, +# scanner user-agents) had no input stream. +# +# Cilium 1.20 renders this into the Gateway listeners' HTTP connection manager +# and writes one JSON line per request to the cilium-envoy container's stdout, +# i.e. /var/log/pods/kube-system_cilium-envoy-*/cilium-envoy/*.log, which the +# node log store (Alloy -> Loki) already tails. +# +# Deliberately NOT logged: +# * no debug/trace Envoy application logging (disk is the constraint here); +# * no request/response headers wholesale and no bodies -- Authorization, +# Cookie and Set-Cookie therefore never reach disk. Only the named fields +# below are emitted, each an explicit command operator. +# +# `client_ip` is the real client identity: Envoy is hostNetwork, so the raw +# peer is cloudflared on the Pi (10.10.0.1). Cloudflare sets CF-Connecting-IP +# and cloudflared forwards it; `peer` and `x_forwarded_for` are kept so a +# missing/forged CF-Connecting-IP is visible rather than silently trusted. +apiVersion: cilium.io/v2alpha1 +kind: CiliumGatewayClassConfig +metadata: + name: cilium + namespace: kube-system +spec: + description: Cilium GatewayClass with HTTP access logging (netsec F7) + telemetry: + accessLogs: + - format: JSON + targets: + - HTTP + json: + gateway: "%CILIUM_GATEWAY_NAMESPACE%/%CILIUM_GATEWAY_NAME%" + start_time: "%START_TIME%" + method: "%REQUEST_HEADER(:METHOD)%" + path: "%REQUEST_HEADER(X-ENVOY-ORIGINAL-PATH?:PATH)%" + protocol: "%PROTOCOL%" + response_code: "%RESPONSE_CODE%" + response_flags: "%RESPONSE_FLAGS%" + duration_ms: "%DURATION%" + bytes_received: "%BYTES_RECEIVED%" + bytes_sent: "%BYTES_SENT%" + authority: "%REQUEST_HEADER(:AUTHORITY)%" + client_ip: "%REQUEST_HEADER(CF-CONNECTING-IP)%" + x_forwarded_for: "%REQUEST_HEADER(X-FORWARDED-FOR)%" + peer: "%DOWNSTREAM_REMOTE_ADDRESS_WITHOUT_PORT%" + user_agent: "%REQUEST_HEADER(USER-AGENT)%" + cf_ray: "%REQUEST_HEADER(CF-RAY)%" + upstream_host: "%UPSTREAM_HOST%" diff --git a/infrastructure/networking/gateway/gatewayclass.yaml b/infrastructure/networking/gateway/gatewayclass.yaml new file mode 100644 index 0000000..db01b84 --- /dev/null +++ b/infrastructure/networking/gateway/gatewayclass.yaml @@ -0,0 +1,23 @@ +# The Cilium GatewayClass, declared here so the access-log configuration is +# bound by GitOps rather than a hand patch. +# +# Why this file exists at all: the cilium Helm chart creates the GatewayClass +# (controllerName io.cilium/gateway-controller) but has no values knob for +# `spec.parametersRef`, and Cilium only reads `spec.telemetry.accessLogs` from +# the CiliumGatewayClassConfig referenced there. Owning the object here keeps +# the binding in sirius/homek8s and applied by Flux. +# +# The rendered spec is byte-for-byte the chart's GatewayClass plus parametersRef, +# so a Helm upgrade and this manifest agree on every other field. +apiVersion: gateway.networking.k8s.io/v1 +kind: GatewayClass +metadata: + name: cilium +spec: + controllerName: io.cilium/gateway-controller + description: The default Cilium GatewayClass + parametersRef: + group: cilium.io + kind: CiliumGatewayClassConfig + name: cilium + namespace: kube-system diff --git a/infrastructure/networking/gateway/kustomization.yaml b/infrastructure/networking/gateway/kustomization.yaml index a64a0c8..ba8b4b8 100644 --- a/infrastructure/networking/gateway/kustomization.yaml +++ b/infrastructure/networking/gateway/kustomization.yaml @@ -3,3 +3,5 @@ kind: Kustomization resources: - namespace.yaml - gateway.yaml + - gatewayclass.yaml + - gatewayclass-config.yaml