Skip to main content

Overview

The Route class represents an OpenShift Route object, which exposes a service at a host name so that external clients can reach it by name. Routes are OpenShift-specific resources that provide advanced features like TLS termination, load balancing, and custom routing. Source: ocp_resources/route.py:5

Class Definition

Constructor

Parameters

str
default:"None"
Name of the Route resource. If not provided, it must be specified in the YAML file.
str
default:"None"
Namespace where the Route will be created. Required for namespaced resources.
DynamicClient
default:"None"
Kubernetes dynamic client for API communication. If not provided, the default client will be used.
str
default:"None"
Name of the Service to expose through this Route. This creates a route targeting the specified service.
str
default:"None"
CA certificate for TLS re-encrypt termination. When provided, the route will be configured with re-encrypt TLS termination.
bool
default:"True"
If True, the resource will be automatically deleted when used as a context manager.
str
default:"None"
Path to a YAML file containing the Route definition. If provided, the Route will be created from this file.
int
default:"TIMEOUT_4MINUTES"
Timeout in seconds for delete operations. Defaults to 4 minutes.
Any
Additional keyword arguments passed to the parent NamespacedResource class. Common options include label and annotations.

Properties

exposed_service

Returns the name of the service that the route is exposing. Source: ocp_resources/route.py:48 Returns: Service name as a string

host

Returns the hostname that is exposing the service externally. Source: ocp_resources/route.py:55 Returns: Host name as a string

ca_cert

Returns the destination CA certificate used for TLS termination. Source: ocp_resources/route.py:62 Returns: CA certificate as a string

termination

Returns the TLS termination type for a secured route (e.g., “edge”, “passthrough”, “reencrypt”). Source: ocp_resources/route.py:69 Returns: Termination type as a string

Usage Examples

Basic Route Creation

Create a simple route that exposes a service:

Secure Route with TLS Re-encryption

Create a route with re-encrypt TLS termination:

Using Context Manager

Automatically clean up the route after use:

Creating from YAML

Create a route from a YAML file:

Accessing Route Properties

Query route properties after creation:

OpenShift-Specific Features

Route Types

  • Unsecured Routes: Basic HTTP routes without TLS
  • Edge Termination: TLS terminates at the router, traffic to backend is HTTP
  • Passthrough Termination: Encrypted traffic passes through to the backend
  • Re-encrypt Termination: TLS terminates at router, re-encrypts to backend

Wildcard Routes

Routes support wildcard subdomains for multi-tenant applications:

Route Annotations

Common annotations for route behavior:
  • haproxy.router.openshift.io/timeout: Set custom timeout
  • haproxy.router.openshift.io/rate-limit-connections: Rate limiting
  • haproxy.router.openshift.io/balance: Load balancing algorithm

See Also