How to deploy distribution package to K8S with a non standard application path?

I want to deploy the Camunda distribution package to a sub-path like “/xyz-process-engine-erave/camunda/” on a Kubernetes environment that runs multiple applications under multiple sub-paths of the same outward facing host.
After some experimentation, the Ingress definition looks like this:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
...
  annotations:
    ...
    nginx.ingress.kubernetes.io/app-root: /xyz-process-engine-erave
    nginx.ingress.kubernetes.io/use-regex: "true"
    nginx.ingress.kubernetes.io/rewrite-target: /$2 
    nginx.ingress.kubernetes.io/redirect-regex: ^/(.*)  
    nginx.ingress.kubernetes.io/redirect-replacement: /xyz-process-engine-erave/$1  
    nginx.ingress.kubernetes.io/x-forwarded-prefix: "true"
    nginx.ingress.kubernetes.io/add-base-url: "true"
    nginx.ingress.kubernetes.io/proxy-redirect-from: "~^/xyz-process-engine-erave/(.*)"
    nginx.ingress.kubernetes.io/proxy-redirect-to: /$1

spec:
  tls:
  ...
  rules:
  - host: abc.def.org
    http:
      paths:
      - path: /xyz-process-engine-erave(/|$)(.*)
        backend:
          serviceName: process-engine-webapp-xxx
          servicePort: 8080

The incoming requests to “https://abc.def.org/xyz-process-engine-erave/camunda/” are routed to the camunda container, but it answers with a redirect to “https://abc.def.org/camunda/”, which is wrong in my environment.

I understand that I need to set a configuration entry or JVM parameter named camunda.bpm.webapp.application-path to sove this problem. But I can’t figure out how to do that. I have found no config file containing this key in the container.

I have tried to set the JAVA_OPTS environment variable, which should be honored by tomcat:

apiVersion: apps/v1  
kind: Deployment
metadata:
  name: process-engine-webapp-xyz
  labels:
  ...
spec:
   ...
  template:
    metadata:
        ...
    spec:
      containers:
      - name: process-engine
        image: camunda/camunda-bpm-platform:latest
        env:
        - name: JAVA_OPTS
          value: "-Dcamunda.bpm.webapp.application-path=/xyz-process-engine-erave"
...       

But this does not seem to make a difference.

Now I am running out of ideas. Is my approach viable at all, or am I doing it all wrong?

The property you’re looking to leverage is for Spring Boot applications, whereas the camunda/camunda-bpm-platform image is built on a tomcat distribution. Though I’ve not seen a clear example of this done properly, I believe the answer lies in configuring Tomcat’s Context Path.

Thank you jgigliotti. It turns out that changing the Tomcat context path by configuration is quite frickle, so I have taken the rather crude approach of moving the directory of the camunda app:

apiVersion: apps/v1
kind: Deployment
...
spec:
...
  template:
    spec:
      containers:
      - name: process-engine
        image: camunda/camunda-bpm-platform:latest
        command:
        - /bin/sh
        - -c
        - |
          echo "change webapp path"
          ls ./webapps
          mkdir ./webapps/xyz-process-engine-erave
          mv ./webapps/camunda ./webapps/xyz-process-engine-erave/camunda
          echo "start camunda"
          ./camunda.sh

This did change the context path, and the pages are loaded from the desired path now. Unfortunately JS and CSS are now loaded from another invalid path:
https://abc.def.org/xyz-process-engine-erave/camunda/app/welcome/$APP_ROOT/app/welcome/styles/styles.css?bust=xxx

Is there a way to tell the application how to set $APP_ROOT properly?

Thanks again.

I think you’re marching into even more difficult territory. I believe the replacement of $APP_ROOT is done in a filter down in Camunda code, not so much dictated by Tomcat.

Your are right. I have finally reverted my attempt and use path translation in the (nginx) ingress instead. This works well for …/engine-rest (which is good enough for me right now) and to some degree with the applications, but eventually fails there with dynamically loaded JS.
So for now I am happy, but I still wonder, what the best practice for what I have tried to accomplish would be? Is there an official way to deploy Camunda to a non-standard path? Should I have used the Spring Boot application instead?

I think in both cases you end up having to configure the context path. In theory, easier in a Spring Boot application than configuring Tomcat. It would be a real shame if the Camunda webapps have to be context aware, but also not configurable.

If I get some extra time in the coming days, I’ll see if I can get a working example (this is a problem for reverse proxy using any location other than / as well). This question comes up enough that having a goto example would be beneficial for the community.

That would be really great, thanks. I volunteer as a tester :slight_smile:

1 Like

Hello, did you came up with a solution for this issue? @Helmut_Hauschild @jgigliotti

I’ve ended up solving the issue by looking at the Camunda Keycload Kubernetes example https://github.com/camunda/camunda-bpm-identity-keycloak/tree/master/examples/sso-kubernetes