Task: Migrate from OCP Route to GatewayAPI Route
TOC
IntroductionPrerequisitesBasic HTTP RouteOCP Route ConfigurationGateway API ConfigurationRoute TimeoutsOCP Route ConfigurationGateway API ConfigurationHTTP Strict Transport Security (HSTS)OCP Route ConfigurationGateway API ConfigurationCookie-Based Session AffinityOCP Route ConfigurationGateway API ConfigurationPath-Based RoutingOCP Route ConfigurationGateway API ConfigurationHeader ModificationOCP Route ConfigurationGateway API ConfigurationConnection LimitsOCP Route ConfigurationGateway API ConfigurationRate LimitingOCP Route ConfigurationGateway API ConfigurationIP Allowlist/BlocklistOCP Route ConfigurationGateway API ConfigurationURL RewriteOCP Route ConfigurationGateway API ConfigurationCross-Namespace Route AdmissionOCP Route ConfigurationGateway API ConfigurationDefault TLS Certificate for IngressOCP Route ConfigurationGateway API ConfigurationTLS Re-encrypt with Custom CAOCP Route ConfigurationGateway API ConfigurationEdge Termination with Custom CertificateOCP Route ConfigurationGateway API ConfigurationTLS PassthroughOCP Route ConfigurationGateway API ConfigurationFeature Comparison SummaryMigration StrategyRelated DocumentationIntroduction
This guide provides detailed instructions for migrating from OpenShift Container Platform (OCP) Routes to Kubernetes Gateway API HTTPRoutes with Envoy Gateway. Each section covers a specific OCP Route feature and its equivalent configuration in Gateway API.
Prerequisites
- Configure EnvoyGatewayCtl
- Configure Gateway
- Basic understanding of Gateway API Routes
Basic HTTP Route
OCP Route Configuration
In OCP, a basic HTTP route is created using the Route resource:
- The hostname for the route
- Backend service reference
- Target port on the backend service
Gateway API Configuration
In Gateway API, the equivalent configuration uses HTTPRoute:
- Hostnames that this route accepts (equivalent to OCP Route's
host) - Reference to the Gateway listener
- Backend service and port
Route Timeouts
OCP Route Configuration
In OCP, timeouts are configured using annotations:
- General timeout for HTTP requests
- Timeout for tunnel connections (WebSocket, HTTP/2, etc.)
Gateway API Configuration
In Gateway API, timeouts are configured in the HTTPRoute rules:
- Request timeout configuration
For more details, see Request Timeouts.
Gateway API does not have a separate timeout specifically for tunnel connections. The request timeout applies to all connection types.
HTTP Strict Transport Security (HSTS)
OCP Route Configuration
In OCP, HSTS is configured using the annotation on edge-terminated or re-encrypt routes:
- HSTS header configuration
Gateway API Configuration
In Gateway API, HSTS is configured using response header modification:
- Add HSTS header to response
For more details, see HTTP Header Modification.
Unlike OCP's requiredHSTSPolicies cluster-wide enforcement, Gateway API requires explicit configuration per route. There is no global HSTS policy enforcement mechanism in Gateway API.
Cookie-Based Session Affinity
OCP Route Configuration
In OCP, session affinity is configured using annotations:
- Load balancing algorithm
- Enable cookie-based session affinity
- Cookie name for session persistence
Gateway API Configuration
In Gateway API, session persistence is configured in the HTTPRoute rules:
- Session persistence configuration
- Cookie lifetime type:
Permanent(persists across browser sessions) orSession(expires when browser closes)
For more details, see Session Affinity/Sticky Sessions.
Path-Based Routing
OCP Route Configuration
In OCP, path-based routing uses the path field:
- Path prefix for matching requests
Gateway API Configuration
In Gateway API, path matching is configured in the HTTPRoute rules:
- Path matching configuration
Gateway API supports multiple match types:
PathPrefix: Matches the path prefix (equivalent to OCP's default behavior)Exact: Matches the exact pathRegularExpression: Matches using regular expressions
For more details, see HTTPRoute Matches.
Header Modification
OCP Route Configuration
In OCP, header modification uses annotations:
- Set response headers
- Set request headers
Gateway API Configuration
In Gateway API, header modification is configured using filters:
- Request header modification
- Response header modification
For more details, see HTTP Header Modification.
Connection Limits
OCP Route Configuration
In OCP, connection limits are configured using annotations:
- Maximum concurrent connections per backend pod
Gateway API Configuration
In Gateway API, connection limits are configured using ClientTrafficPolicy attached to the Gateway:
- Attach policy to Gateway
- Connection limit configuration
For more details, see Connection Limit.
Unlike OCP's per-backend pod limit, Gateway API's connection limit is applied at the Gateway level and is distributed across Envoy proxy instances.
Rate Limiting
OCP Route Configuration
In OCP, rate limiting uses annotations:
- Rate limiting configuration
Gateway API Configuration
In Gateway API, rate limiting is configured using BackendTrafficPolicy:
- Rate limiting configuration
For more details, see Rate Limiting.
Gateway API rate limiting is more flexible than OCP Route annotations and supports both local and global rate limiting mechanisms.
IP Allowlist/Blocklist
OCP Route Configuration
In OCP, IP allowlisting uses annotations:
- IP allowlist configuration
Gateway API Configuration
In Gateway API, IP filtering is implemented using SecurityPolicy with authorization rules:
- Attach policy to HTTPRoute
- Authorization configuration with default deny
- IP allowlist using CIDR notation
For IP blocklist (denylist), set defaultAction: Allow and use action: Deny:
- Default action allows all traffic
- Deny traffic from specific IPs
For more details, see IP Allowlist/Denylist.
Ensure you configure the client IP detection correctly using ClientTrafficPolicy if your Gateway is behind a load balancer or proxy.
URL Rewrite
OCP Route Configuration
In OCP, URL rewriting uses the annotation:
- Rewrite target path
Gateway API Configuration
In Gateway API, URL rewriting is configured using filters:
- URL rewrite filter
For more details, see URL Rewrite.
Cross-Namespace Route Admission
OCP Route Configuration
In OCP, the route admission policy controls whether routes in different namespaces can claim the same hostname. This is configured at the cluster level through the Ingress Operator.
Gateway API Configuration
In Gateway API, cross-namespace access is controlled at the Gateway listener level:
- Configure which namespaces can attach routes
Options for allowedRoutes.namespaces.from:
Same: Only routes in the same namespace as the GatewayAll: Routes from any namespaceSelector: Routes from namespaces matching a label selector
For more details, see Cross-Namespace Routing.
Unlike OCP's cluster-wide admission policy, Gateway API controls this at the individual Gateway listener level, providing more granular control.
Default TLS Certificate for Ingress
OCP Route Configuration
In OCP, routes without TLS configuration can use a default certificate configured at the Ingress Controller level.
Gateway API Configuration
In Gateway API, configure a default TLS certificate on the Gateway listener:
- Default TLS certificate for the listener
Any HTTPRoute attached to this listener without specific TLS configuration will use this default certificate.
TLS Re-encrypt with Custom CA
OCP Route Configuration
In OCP, re-encrypt routes terminate TLS at the router and re-encrypt to the backend with validation:
- Re-encrypt termination mode
- CA certificate for validating backend
Gateway API Configuration
In Gateway API, backend TLS validation is configured using BackendTLSPolicy:
- Terminate TLS at the Gateway
- Apply policy to the backend Service
- Backend TLS validation configuration
For more details, see Backend TLS.
The CA certificate must be stored in a ConfigMap, not a Secret.
Edge Termination with Custom Certificate
OCP Route Configuration
In OCP, edge termination uses the route's TLS configuration:
- Edge termination mode
- TLS certificate
- TLS private key
Gateway API Configuration
In Gateway API, TLS termination is configured on the Gateway listener:
- TLS secret type
- HTTPS protocol
- Terminate TLS mode
- Reference to TLS secret
TLS Passthrough
OCP Route Configuration
In OCP, passthrough routes do not terminate TLS:
- Passthrough termination mode
Gateway API Configuration
In Gateway API, TLS passthrough uses TLSRoute:
- TLS protocol
- Passthrough mode
- SNI hostname for routing
For more details, see TLS Passthrough and TLSRoute specification.
TLSRoute uses SNI (Server Name Indication) for routing decisions without terminating TLS. This means:
- No access to HTTP headers or request content for routing decisions
- No L7 filters (header modification, URL rewrite, etc.) can be applied
- Routing is purely based on the SNI hostname
Feature Comparison Summary
Migration Strategy
When migrating from OCP Routes to Gateway API:
-
Start with a Gateway: Create a Gateway resource with appropriate listeners for your use case
- Deploy the Gateway in the same namespace or a dedicated gateway namespace
- Configure listeners for all protocols you need (HTTP, HTTPS, TLS, TCP, UDP)
- Ensure the Gateway service is created and has an accessible endpoint
-
Convert Routes to HTTPRoutes: Migrate each OCP Route to an HTTPRoute, starting with simple routes
- Begin with non-production or low-traffic routes to minimize risk
- Verify hostname and path matching configurations
- Test basic connectivity before adding advanced features
-
Apply Policies: For features that require policies (BackendTrafficPolicy, SecurityPolicy, ClientTrafficPolicy), create and attach them after the basic route is working
- Add one policy at a time and validate functionality
- Monitor for any unexpected behavior or performance impact
-
Test Incrementally: Validate each migration step before proceeding to the next route
- Monitoring: Check Gateway and Route status conditions for any errors
- Functional Testing: Verify all routes work as expected with curl or automated tests
- Performance Testing: Compare response times and throughput with OCP Routes
- Validation Checks:
- Verify TLS certificates are correctly applied
- Test session affinity and load balancing behavior
- Validate rate limiting and security policies
- Check header modification and URL rewrites
-
Update DNS: Once validated, update DNS entries to point to the new Gateway service
- Dual-Running Period (recommended): Point a subset of traffic to the new Gateway while keeping OCP Routes active for rollback capability
- Gradually shift traffic using weighted DNS or canary deployments
- Monitor error rates, latency, and application metrics during cutover
-
Rollback Procedures: If issues are discovered after migration
- Revert DNS to point back to OCP Routes
- Keep OCP Routes active for at least 24-48 hours after DNS cutover
- Document any configuration differences that caused issues
- Have a communication plan for stakeholders if rollback is needed