Configure GatewayAPI Policy
TOC
OverviewPrerequisitesPolicy Attachment BasicsPolicy Attachment SummaryCreate Policies in Web ConsoleSecurityPolicyConfiguration Via Web ConsoleAPI Key AuthenticationCORS ConfigurationConfiguration Via YAMLReferenceFeaturesHow It WorksNotesOfficial DocumentationBackendTLSPolicyConfiguration Via Web ConsoleConfiguration Via YAMLReferenceFeaturesNotesOfficial DocumentationClientTrafficPolicyConfiguration Via Web ConsoleConfiguration Via YAMLReferenceFeaturesNotesOfficial DocumentationBackendTrafficPolicyConfiguration Via Web ConsoleConfiguration Via YAMLReferenceFeaturesNotesOfficial DocumentationRelated TasksOverview
This document explains how to configure policy resources after Gateway and Route resources are ready. Policies use
the Policy Attachment pattern through .spec.targetRefs to attach additional traffic, security, and backend behavior
to supported resources.
In the recommended workflow, this document comes after Configure GatewayAPI Route.
Envoy Gateway currently provides four policy types: SecurityPolicy, BackendTLSPolicy, ClientTrafficPolicy, and
BackendTrafficPolicy.
Prerequisites
Please ensure that you have completed the following before proceeding:
- Read Configure GatewayAPI Gateway and Configure GatewayAPI Route
- Created the target resource that the policy will attach to, such as a
Gateway,Route, orService
Policy Attachment Basics
Policies attach to other resources through .spec.targetRefs.
By default, a policy can only attach to resources in the same namespace.
For Gateway targets, sectionName can be used to target a specific listener when the policy type supports it. For
Service targets, sectionName refers to the Service port name.
Policy Attachment Summary
sectionName is used to target a specific listener on a Gateway or a specific port on a Service. When omitted or
set to ALL, the policy applies to all listeners or ports.
Create Policies in Web Console
All policy types are created from the same entry:
- Navigate to
Alauda Container Platform -> Networking -> Gateway -> Policies - Select the required value in the
Policy Typedropdown - Click the
Create Policybutton
The following sections focus only on the fields that are specific to each policy type.
SecurityPolicy
Configuration Via Web Console
Common Fields (shared for all policies):
SecurityPolicy Specific Fields:
API Key Authentication
CORS Configuration
Configuration Via YAML
Reference
SecurityPolicy is used to configure authentication, authorization, and other security-related features for your Gateway and Routes. It provides a declarative way to protect your services by validating incoming requests before they reach your backend applications.
Features
- Authentication: Verify the identity of clients using various methods (API Key, JWT, OIDC, Basic Auth)
- Authorization: Control access to resources based on validated credentials
- CORS Configuration: Manage Cross-Origin Resource Sharing policies
How It Works
- Create a SecurityPolicy with your desired authentication/authorization rules
- Attach it to a specific Gateway, HTTPRoute, or GRPCRoute
- Envoy Gateway validates incoming requests according to the policy
- Valid requests are forwarded to backend services; invalid requests are rejected with appropriate HTTP status codes
Notes
- The web console currently supports configuring API Key Authentication and CORS. For other authentication methods and advanced security features, you need to use YAML configuration.
- Each Route can only be associated with one SecurityPolicy.
- If a SecurityPolicy references a secret with no values, all requests to the attached route will be rejected with
401 Unauthorized. - In the web console, by default, the
Extract Fromfield is set toheaderand theHeader Namefield is set toauthorization. - You can view which policies are attached to a route by navigating to the Route's topology tab in the web console.
Official Documentation
BackendTLSPolicy
Configuration Via Web Console
Common Fields:
BackendTLSPolicy Specific Fields:
CACertificateRefs Configuration:
When creating or selecting a CA certificate secret:
- The secret type must be suitable for CA certificates
- The key must be
ca.crt - You can import a certificate file, which must start with
-----BEGIN CERTIFICATE-----and end with-----END CERTIFICATE----- - When importing an invalid certificate format, an error message "must contain PEM-encoded TLS certificates" will be displayed
- When selecting an existing secret without
ca.crtkey, an error message "must have ca.crt key" will be displayed
Configuration Via YAML
Reference
BackendTLSPolicy controls the TLS configuration between Envoy Gateway and backend services. It allows you to configure:
- SNI (Server Name Indication): The hostname used when establishing TLS connections to backends
- Certificate Validation: How to validate backend server certificates
- CA Certificates: Custom CA certificates for validating backend certificates
Features
- Configure TLS settings for connections to backend services
- Support for custom CA certificates or system well-known CA certificates
- SNI configuration for proper TLS handshake
Notes
- The
sectionNameintargetRefscorresponds to the port name of the Service. - When using
WellKnownCACertificates, the system's default CA certificates are used for validation. - The hostname is required and is used as the SNI value when Envoy connects to the backend.
Official Documentation
ClientTrafficPolicy
Configuration Via Web Console
Common Fields:
Timeout Configuration (Options):
Configuration Via YAML
Reference
ClientTrafficPolicy controls the behavior of connections from clients to Envoy Gateway. It provides fine-grained control over:
- TCP Settings: Connection-level timeout and keepalive settings
- HTTP Settings: Request/response timeouts and HTTP protocol behavior
Features
- Configure TCP connection idle timeouts
- Control HTTP request reception timeouts
- Set HTTP connection idle timeouts
- Configure HTTP stream idle timeouts
Notes
- Timeout values are specified as duration strings (e.g., "30s", "5m", "1h").
Official Documentation
BackendTrafficPolicy
Configuration Via Web Console
Common Fields:
Timeout Configuration (Options):
Configuration Via YAML
Reference
BackendTrafficPolicy controls the behavior of connections from Envoy Gateway to backend services. It provides fine-grained control over:
- TCP Settings: Connection establishment timeouts
- HTTP Settings: Connection durations, idle timeouts, and request timeouts
Features
- Configure TCP connection establishment timeouts
- Control HTTP connection idle timeouts
- Set maximum HTTP connection durations
- Configure HTTP request timeouts
Notes
- Timeout values are specified as duration strings (e.g., "30s", "5m", "1h").
- The
requestTimeoutfield supports setting to "unlimited" to disable the timeout.
Official Documentation
Related Tasks
After policies are attached, continue with Tasks for Envoy Gateway for more operational examples and advanced configuration tasks.