Ingress objects create Route objects with the wrong port

Solution Verified - Updated -

Issue

  • When you create an Ingress object in OpenShift Container Platform, then the generated Route object has the targetPort of the Pod assigned, not the one of the Service (should be http-default):

    $ oc apply -f - << EOF
    apiVersion: v1
    kind: Service
    metadata:
    name: app
    spec:
    ports:
    - name: http-default
      port: 8080
      protocol: TCP
      targetPort: default
    selector:
      deployment: app
    EOF
    
    $ oc apply -f - << EOF
    apiVersion: extensions/v1beta1
    kind: Ingress
    metadata:
    name: app
    spec:
    rules:
    - host: app.test.com
      http:
        paths:
        - backend:
            serviceName: app
            servicePort: http-default
          path: /
    EOF
    
    $ oc get route app-6dqpg -o yaml
    apiVersion: route.openshift.io/v1
    kind: Route
    metadata:
    [...]
    spec:
    host: app.test.com
    path: /
    port:
      targetPort: default
    to:
      kind: Service
      name: app
    [...]
    
    

Environment

  • Red Hat OpenShift Container Platform (OCP) 3.11

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In