We have deployed services that expect to be called with /{service_path} and we’d like to access some of them through ${PROXY_IP}/something/{service_path} instead of ${PROXY_IP}/{service_path}.
I guess we have to create a new KongIngress that somehow uses proxy rules to change the path but I couldn’t find more documentation than this and I don’t know how to proceed.
How can we define a regex to remove “/something/” from the path?
I expect this configuration to proxy calls to “/staging/myservice/” to myservice using as path “/myservice/” however it seems that the property proxy.path is not adding “/myservice/” to the stripped path. For example if I call “/staging/myservice/ui” in the service logs it shows:
2019-06-29 12:05:20.257 CEST 10.56.2.28 - - [29/Jun/2019:10:05:20 +0000] "GET /ui HTTP/1.1" 404 206 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/75.0.3770.90 Chrome/75.0.3770.90 Safari/537.36"
In addition, if this would work I’d like to make the kongingress-api-staging more generic to work with many services ("/staging/mysecondservice/", “/staging/mythirdservice/”, and so on )
To configure any specific setting for a Kong service object, you will need to put the configuration.konghq.com annotation on the Kubernetes service resource (since a k8s service maps to a Kong service).
So, you need to add that annotation myservice service resource.
I can see in Konga how the proxy.path property is not being set even though is defined in the KongIngress resource (but the strip_path property is working ok). If I change the path in the service details section in Konga the redirection works.
Allow me to explain.
When you use configuration.konghq.com annotation on Ingress resource, it overrides the properties of the routes corresponding to that particular ingress resource.
When you the same annotation on the service resource, it overrides the the properties of the service in Kong.
The value of the annotation should be the name of the KongIngress resource that you would like to reference.
In this case, you want to reference kongingress-api-staging KongIngress resource on the myservice resource so that the Kong service path property is overriden with /myservice/.
And that is why the annotation should be present on the Ingress as well as Service resource.
According to the documentation, (here), it is enough to use the same name for the Ingress and KongIngress resource. I have however observed the same as @fgsalomon where the strip_path property is applied but not the path property until you add the annotation to the Service, so is the documentation wrong or am I missing something? (I’m rather new to Kubernetes and still haven’t fully grasped the Ingress concept I think).