zalando / skipper

An HTTP router and reverse proxy for service composition, including use cases like Kubernetes Ingress
https://opensource.zalando.com/skipper/
Other
3.07k stars 347 forks source link

Be able to target "dynamic" backend containing variable extracted from PathSubtree #1182

Open jeremycolin opened 5 years ago

jeremycolin commented 5 years ago

Is your feature request related to a problem? Please describe.

We have 2 use cases:

  1. We are deploying code branches to a cluster say custer-test. Those branches can be accessed with https://domain/branches/:buildVersion ie https://domain/branches/pr-123

We have a unique skipper route mapping those to a single unique host: https://domain-branches.

Every branch deployment then exposes its own ingress with the following:

    zalando.org/skipper-predicate: PathSubtree("/{{{BUILD_VERSION}}}")
    zalando.org/skipper-filter: compress() -> modPath("^/{{{BUILD_VERSION}}}", "")

We then have a kubernetes ingress exposing this single unique host but every ingress "filters out" the request if its not its own BUILD_VERSION.

  1. When using stackset with stateful code logic where we do an API call from the browser to our stack. Currently it is mapped to the generic hostname of the stack. ie https://engine We want to be able to route calls such as /api/:buildVersion/ to the correct buildVersion stack. Currently it is not possible to do it at skipper level easily so we have again different ingress (managed by stacksets in this case) with the same logic skipper-predicate, skipper-filter combo to handle the traffic correctly.

Downsides in both cases:

Describe the solution you would like Be able to extract route parameter such as buildVersion in /api/:buildVersion/... and target dynamically a backend as a result: https://engine.buildVersion

Describe alternatives you've considered (optional) Already described above with kubernetes ingress and skipper-filter / skipper-predicate

Additional context (optional) I am a Zalando employee and this is for Zalando internal use cases. Can provide more detalled information on our current setup.

Would you like to work on it? No

szuecs commented 5 years ago

Thanks for describing the issue!

AlexanderYastrebov commented 3 years ago

If I get it right the idea is to use path parameter in the backend hostname.

This is possible with a help of template placeholders and a route:

PathSubtree("/api/:buildVersion") -> 
setRequestHeader("X-Backend", "https://${buildVersion}-domain.test") -> 
setDynamicBackendUrlFromHeader("X-Backend") -> 
setPath("/") -> 
<dynamic>

Note that setDynamicBackendUrlFromHeader does not change path, setPath filter can be used for that. We may think about adding template placeholder support directly into setDynamicBackend* filters to avoid auxiliary header.

szuecs commented 3 years ago

@jeremycolin can you check if @AlexanderYastrebov got your feature request correctly? thanks!