hello-kubernetes
hello-kubernetes copied to clipboard
Handlebar value injection refactor necessary to prevent unstyled content and missing images on missing env var
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):
I suggest adding the slash at the end of the injected env var here: https://github.com/paulbouwer/hello-kubernetes/blob/6e9ac0e273bfdaf1f9b78501e8b046be00d44eb3/src/app/server.js#L22 - 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