Is there any way to do name based routing in Kubernetes

4/2/2019

We are trying to dockerize a set of webapps hosted on a JBoss Wildfly Server hosted in HA (Node 1 & Node 2) configuration. There is an F5 load balancer server in front of the JBoss server performing sticky session based load balancing. So as far as F5 is concerned there is only one port (443) that it listens on and forwards the request to the JBoss Node 1 or Node 2. So, F5 did not need to have any information about the separate apps (for e.g. https://domain.name/app1 & https://domain.name/app2) hosted on the JBoss server.

Now we are dockerizing each webapp into its own container and wrapped as a Kubernettes pod. On the Kubernettes service layer each of the app (/app1 & /app2) are hosted at separate ports. So each application gets its own port.

What load balancing architectural options do I have and could you point me at some relevant reading material? 1) Can F5 somehow consume metadata about which URL context path (/app1 or /app2) and route it to the appropriate port on the Kubernettes service layer? 2) If F5 cannot do any context path based routing on F5, then can some of this app-to-port routing be done via some Kuberneetes config?

-- Vijay Tamhankar
kubernetes

1 Answer

4/3/2019

You may need an ingress controller for this. You can get detailed info about ingress controller over https://kubernetes.io/docs/concepts/services-networking/ingress/

Typical Ingress looks like this

Over the point of yours "On the Kubernetes service layer each of the app (/app1 & /app2) are hosted at separate ports. So each application gets its own port." Below Given example is for ingress controller considering your service name for app1 is app1-svc and for app2 is app2-svc

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: foo-https
  annotations:
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
    nginx.ingress.kubernetes.io/secure-backends: "true"
spec:
  tls:
   - hosts:
     - domain.name
  rules:
  - host: domain.name 
    http:
      paths:
      - path: /app1
        backend:
          serviceName: app1-svc
          servicePort: 443
      - path: /app2
        backend:
          serviceName: app2-svc
          servicePort: 443
-- Vikas Kumar
Source: StackOverflow