Routes¶
OpenShift Only
Routes are OpenShift objects that expose a Service at a hostname, so clients outside the cluster can reach it. The cluster's router (HAProxy-based) receives the traffic on ports 80 and 443 and forwards it to the Service's pods.
- A Route can be unsecured (HTTP) or secured with TLS using
edge,passthroughorreencrypttermination. - If you don't set a hostname, OpenShift generates one:
<route-name>-<project>.<apps-domain>. oc expose servicecreates a Route that takes its name from the Service, unless you pass--name.- Routes can split traffic between several Services by weight, which is useful for blue-green and canary releases.
For portable manifests you can also use a Kubernetes Ingress, which OpenShift converts into a Route.
Resources¶
References¶
Route
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: frontend
spec:
to:
kind: Service
name: frontend
port:
targetPort: 8080
Secured (edge) Route that redirects HTTP to HTTPS
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: frontend-secure
spec:
to:
kind: Service
name: frontend
port:
targetPort: 8080
tls:
termination: edge
insecureEdgeTerminationPolicy: Redirect
Canary: send 10% of traffic to a new version
apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: frontend-canary
spec:
to:
kind: Service
name: frontend
weight: 90
alternateBackends:
- kind: Service
name: frontend-v2
weight: 10
port:
targetPort: 8080