Kubernetes: Replace mod_cluster for back end services (reverse proxy)

6/13/2018

I am migrating my current service to Kubernetes. Currently back end services are resolved via mod_cluster. mod cluster manager runs on httpd and mod_cluster clients auto register their web contexts with httpd/mod_cluster manager on startup

user-->ingress-rule--> httpd [running mod_cluster manager]--> Jboss[mod_cluster clients]

I resolve my UI via the following ingress rule

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: httpd
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
    nginx.ingress.kubernetes.io/ssl-passthrough: "true"
spec:
  rules:
  - host: myk8s.myath.myserv.com
    http:
      paths:
      - path: /
        backend:
          serviceName: httpd
          servicePort: 443
  tls:
  - hosts:
    - myk8s.myath.myserv.com

This works well, resolves UI, can log in and resolve all static content etc.

Mod cluster exposes services such as myservice. I disabled mod_cluster and created a Kubernetes service myservice that resolved to the back-end Pod thinking that the Ingress rule would get the request as far as httpd and then httpd would be able to resolve the backend service via Kubernetes but i get 404s as I am unable to resolve myservice

Service can be resolved via Reverse proxy rules such as below, but this is not preferred solution

# Redirect to myjbossserv
ProxyPass /myservice/services/command/  http://myjbossserv:8080/myservice/services/command/          <-----myjbossserv is a service registered in kubernetes
ProxyPassReverse /myservice/services/command/  http://myjbossserv:8080/myservice/services/command/

Any help much appreciated

-- user1843591
docker
kubernetes
mod-cluster
nginx
reverse-proxy

1 Answer

1/6/2019

The simplest way to solve this...catering for all HA and robustness use cases was to use reverse proxy rules. There are multiple ways to configure these such as at image build time or via config maps...

# Redirect to myjbossserv
ProxyPass /myservice/services/command/  http://myjbossserv:8080/myservice/services/command/          <-----myjbossserv is a service registered in kubernetes
ProxyPassReverse /myservice/services/command/  http://myjbossserv:8080/myservice/services/command/
-- user1843591
Source: StackOverflow