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

2

26

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

Chub answered 6/1, 2017 at 3:45 Comment(0)
A
31

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.

Alleris answered 6/1, 2017 at 4:42 Comment(2)
Routes also is geared towards multitenancy, so there is support in Routes that is not yet available in Ingress to prevent namespace A from "stealing" the host name that belongs to namespace B. The openshift HAProxy router (ingress controller) is also more mature and has gone through a fair amount of security hardening (invalid SSL certificates are not allowed), etc.Jecon
thanks. Another question, I need to expose UDP port to external, can route do UDP? I didnt find any example in openshift document.Chub
B
-1

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
}
Breakage answered 19/3, 2019 at 11:16 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.