| name | eg-client-policy |
| description | Configure client-facing traffic policies -- timeouts, connection limits, TLS settings, HTTP behavior |
| arguments | [{"name":"Feature","description":"Feature to configure: timeout, connection, tls, http, all (default: all)","required":false}] |
Envoy Gateway Client Traffic Policy
Generate ClientTrafficPolicy resources to configure how Envoy Proxy handles downstream
client connections. This includes timeouts, connection limits, TLS client settings,
HTTP protocol behavior, IP detection, and header management.
ClientTrafficPolicy attaches to Gateway resources (not Routes) and configures the
listener-level behavior for all traffic entering through that Gateway.
Instructions
Step 1: Create the ClientTrafficPolicy
ClientTrafficPolicy targets a Gateway. A section-specific policy (targeting a named
listener) takes precedence over a gateway-wide policy.
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
name: client-policy
namespace: default
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
Step 2: Client Timeouts
Configure timeouts to protect Envoy from slow clients and prevent resource exhaustion.
Never rely on Envoy defaults -- set explicit timeouts.
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
timeout:
http:
requestReceivedTimeout: 30s
idleTimeout: 120s
tcp:
idleTimeout: 3600s
Step 3: Connection Management
Control connection limits and buffer sizes to protect Envoy under load.
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
connection:
connectionLimit:
value: 10000
bufferLimit: 32768
tcpKeepalive:
probes: 3
idleTime: 60s
interval: 10s
Step 4: TLS Client Settings
Configure TLS termination behavior for HTTPS listeners.
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
sectionName: https
tls:
minVersion: "1.2"
maxVersion: "1.3"
ciphers:
- ECDHE-ECDSA-AES128-GCM-SHA256
- ECDHE-RSA-AES128-GCM-SHA256
- ECDHE-ECDSA-AES256-GCM-SHA384
- ECDHE-RSA-AES256-GCM-SHA384
- ECDHE-ECDSA-CHACHA20-POLY1305
- ECDHE-RSA-CHACHA20-POLY1305
alpnProtocols:
- h2
- http/1.1
mTLS (Mutual TLS) -- require client certificates
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
sectionName: https
tls:
minVersion: "1.2"
clientValidation:
caCertificateRefs:
- name: trusted-client-ca
group: ""
kind: ConfigMap
optional: false
Create the CA ConfigMap:
apiVersion: v1
kind: ConfigMap
metadata:
name: trusted-client-ca
data:
ca.crt: |
-----BEGIN CERTIFICATE-----
# TODO: paste your CA certificate PEM here
-----END CERTIFICATE-----
Step 5: HTTP Protocol Behavior
Configure HTTP/1.1 and HTTP/2 protocol settings, path normalization, and header handling.
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
http2:
maxConcurrentStreams: 100
path:
escapedSlashesAction: UnescapeAndRedirect
disableMergeSlashes: false
headers:
withUnderscoresAction: RejectRequest
preserveXRequestID: true
enableEnvoyHeaders: false
Step 6: Client IP Detection
Configure how Envoy determines the true client IP address. Critical for accurate
access logging, rate limiting, and authorization decisions.
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
clientIPDetection:
xForwardedFor:
numTrustedHops: 0
Step 7: Proxy Protocol
If Envoy is behind a TCP load balancer that sends PROXY protocol headers (e.g., AWS NLB):
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
proxyProtocol:
versions:
- V1
- V2
Step 8: Complete Production ClientTrafficPolicy
Here is a comprehensive production-ready example:
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
name: production-client-policy
namespace: default
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
timeout:
http:
requestReceivedTimeout: 30s
idleTimeout: 120s
tcp:
idleTimeout: 3600s
connection:
connectionLimit:
value: 10000
bufferLimit: 32768
tcpKeepalive:
probes: 3
idleTime: 60s
interval: 10s
tls:
minVersion: "1.2"
ciphers:
- ECDHE-ECDSA-AES128-GCM-SHA256
- ECDHE-RSA-AES128-GCM-SHA256
- ECDHE-ECDSA-AES256-GCM-SHA384
- ECDHE-RSA-AES256-GCM-SHA384
alpnProtocols:
- h2
- http/1.1
http2:
maxConcurrentStreams: 100
path:
escapedSlashesAction: UnescapeAndRedirect
disableMergeSlashes: false
headers:
withUnderscoresAction: RejectRequest
preserveXRequestID: true
enableEnvoyHeaders: false
clientIPDetection:
xForwardedFor:
numTrustedHops: 0
Step 9: Listener-Specific Policy Override
You can create a more specific policy for a single listener that overrides the
gateway-wide policy:
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
name: gateway-defaults
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
timeout:
http:
idleTimeout: 120s
---
apiVersion: gateway.envoyproxy.io/v1alpha1
kind: ClientTrafficPolicy
metadata:
name: https-strict-tls
spec:
targetRefs:
- group: gateway.networking.k8s.io
kind: Gateway
name: eg
sectionName: https
tls:
minVersion: "1.3"
clientValidation:
caCertificateRefs:
- name: trusted-client-ca
group: ""
kind: ConfigMap
optional: false
timeout:
http:
idleTimeout: 60s
Checklist