OpenShift 4 routes getting created with default *.apps subdomain for custom ingress controller

Solution Verified - Updated -

Issue

  • In OpenShift 3, the following router environment variables were available to make sure the route with labels or route created in labeled namespace gets created with a custom domain as per router sharding.

    • ROUTER_OVERRIDE_HOSTNAME
    • ROUTER_SUBDOMAIN
  • However, these router variables can't be set in OpenShift 4 as everything is managed by ingress operator and any changes in the deployment config of the router will get reverted back.

  • Along with default ingresscontroller, an additional custom ingresscontroller with sharding by using namespace labels is configured. Even after labelling the namespace with correct label, the route gets created with default *.apps subdomain when the hostname with required subdomain in spec.host isn't specified.

$ oc get ingresscontrollers -n openshift-ingress-operator 
NAME                        AGE
custom-ingress-controller   50s
default                     3d17h

$ oc get ingresscontroller default -oyaml -n openshift-ingress-operator
...
spec:
  domain: apps.cluster.domain.com
  endpointPublishingStrategy:
    hostNetwork:
      httpPort: 80
      httpsPort: 443
      protocol: TCP
      statsPort: 1936
    type: HostNetwork
  namespaceSelector:
    matchExpressions:
    - key: route
      operator: NotIn
      values:
      - internal
  replicas: 2
  tuningOptions:
    reloadInterval: 0s

$ oc get ingresscontroller custom-ingress-controller -oyaml -n openshift-ingress-operator
...
spec:
  domain: apps.custom-ingress.example.com
  endpointPublishingStrategy:
    hostNetwork:
      httpPort: 80
      httpsPort: 443
      protocol: TCP
      statsPort: 1936
    type: HostNetwork
  namespaceSelector:
    matchLabels:
      route: internal
  replicas: 1
  tuningOptions:
    reloadInterval: 0s

$ oc label namespace test route="internal"
namespace/test labeled

$ cat route 
kind: Route
apiVersion: route.openshift.io/v1
metadata:
  name: test
  namespace: test
  labels:
    route: internal
spec:
  to:
    kind: Service
    name: httpd-24 
    weight: 100
  port:
    targetPort: 8080-tcp 
  tls:
    termination: edge
  wildcardPolicy: None

$ oc create -f route 
route.route.openshift.io/test created

$ oc get route
NAME   HOST/PORT                                       PATH       SERVICES   PORT       TERMINATION   WILDCARD
test   test-test.apps.cluster.domain.com               httpd-24   8080-tcp   edge          None

Environment

  • Red Hat OpenShift Container Platform (OCP)
    • 4.11+

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase, tools, and much more.

Current Customers and Partners

Log in for full access

Log In

New to Red Hat?

Learn more about Red Hat subscriptions

Using a Red Hat product through a public cloud?

How to access this content