what's the difference between openshift route and k8s ingress?

1/6/2017

I'm new to openshift and k8s. I'm not sure what's the difference between these two terms, openshift route vs k8s ingress ?

-- Feng Xi
kubernetes
openshift
openshift-origin

2 Answers

3/19/2019

The following code implementation will create a route in OCP. The OCP will consider the ingress as a route in the same way.

// build the ingress/route object
func (r *ReconcileMobileSecurityService) buildAppIngress(m *mobilesecurityservicev1alpha1.MobileSecurityService) *v1beta1.Ingress {
    ls := getAppLabels(m.Name)
    hostName := m.Name + "-" + m.Namespace + "." + m.Spec.ClusterHost + ".nip.io"
    ing := &v1beta1.Ingress{
        TypeMeta: v1.TypeMeta{
            APIVersion: "extensions/v1beta1",
            Kind:       "Ingress",
        },
        ObjectMeta: v1.ObjectMeta{
            Name:      m.Name,
            Namespace: m.Namespace,
            Labels:    ls,
        },
        Spec: v1beta1.IngressSpec{
            Backend: &v1beta1.IngressBackend{
                ServiceName: m.Name,
                ServicePort: intstr.FromInt(int(m.Spec.Port)),
            },
            Rules: []v1beta1.IngressRule{
                {
                    Host: hostName,
                    IngressRuleValue: v1beta1.IngressRuleValue{
                        HTTP: &v1beta1.HTTPIngressRuleValue{
                            Paths: []v1beta1.HTTPIngressPath{
                                {
                                    Backend: v1beta1.IngressBackend{
                                        ServiceName: m.Name,
                                        ServicePort: intstr.FromInt(int(m.Spec.Port)),
                                    },
                                    Path: "/",
                                },
                            },
                        },
                    },
                },
            },
        },
    }

    // Set MobileSecurityService instance as the owner and controller
    controllerutil.SetControllerReference(m, ing, r.scheme)
    return ing
}
-- Camila Macedo
Source: StackOverflow

1/6/2017

Ultimately they are intended to achieve the same end. Originally Kubernetes had no such concept and so in OpenShift the concept of a Route was developed, along with the bits for providing a load balancing proxy etc. In time it was seen as being useful to have something like this in Kubernetes, so using Route from OpenShift as a starting point for what could be done, Ingress was developed for Kubernetes. In the Ingress version they went for a more generic rules based system so how you specify them looks different, but the intent is to effectively be able to do the same thing.

-- Graham Dumpleton
Source: StackOverflow