paulbouwer/hello-kubernetes

Handlebar value injection refactor necessary to prevent unstyled content and missing images on missing env var

hotspoons opened this issue · 1 comments

This and this - the leading slash in the template causes this to occur when RENDER_PATH_PREFIX is undefined and the context root of the application is not / (e.g. this container is deployed to a path behind a LB on a route):

image

I suggest adding the slash at the end of the injected env var here:

'/' + process.env.RENDER_PATH_PREFIX.replace(/^[\\/]+/, '').replace(/[\\/]+$/, '') :
- a trailing slash, even if redundant should not affect route resolution, so it would be a safer default IMO.

I succeed to do it by adding the env variable :

  • name: RENDER_PATH_PREFIX
    value: [yourPathprefix]
    And it work with an nginx ingress :
    Annotation:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/configuration-snippet: |
    rewrite ^(/[yourPathprefix])$ $1/ redirect;
    nginx.ingress.kubernetes.io/rewrite-target: /$2

And in your backend something like this :

  • backend:
    service:
    name: demo-svc
    port:
    number: 80
    path: /yourPathprefix(.*)
    pathType: Prefix