[request] Versioning of APIs and Microservices #7200
Replies: 12 comments
-
This is a great suggestion and pretty well detailed. In the absence of this feature in Kong, how are others dealing with versioning? If I have
It looks like I can add two APIs to Kong like so and that would make sure all requests get routed to the appropriate service: For foo-service.v1:
and for foo-service.v2:
But now Kong has no idea about my individual endpoints, the reals APIs of foo-service. Consequently, I can't really use plugins like ACL to secure my APIs. It is likely that I'm missing something here. Anyone has thoughts on how to add all endpoints of foo-service into Kong while still being able to call the two versions as |
Beta Was this translation helpful? Give feedback.
-
Before going further, I will clarify that Kong has no concept of "endpoints" on the services it proxies. Kong proxies whatever comes its way, and does not know if the requested URI matches one of your services' endpoints or not. So Kong will send any incoming request to the corresponding upstream service. Aka: Kong does not support any versioning, by doing this you simply configure two different APIs, pointing to two different locations. Now, my understanding is also that you wish to apply an ACL plugin to both of your versions, and wish to not duplicate the plugin, but have it active on both APIs? If so, that is currently not possible, as plugins are currently tied to only 1 API at a time. This relates to #505. Now about this issue, I do think it makes sense and I think @montanaflynn's description of the desired behavior is both precise and good enough. Having one API being able to point to multiple locations to address versioning is something to look forward to. But this is currently not implemented. |
Beta Was this translation helpful? Give feedback.
-
Thanks @thibaultcha I'll just create different APIs for each path that needs to go through ACL. I'll need to create them twice and apply ACL to them individually. Thats fine for now. To add version prefixes to my APIs (so that I could do Something like so: For foo-service.v1:
and for foo-service.v2:
With the above:
And I can use ACL for my actual API |
Beta Was this translation helpful? Give feedback.
-
Guys, I think that we can create a plugin for Header redirects will be great. Look the ideia bellow: Service version 1: {
"name": "foo-service.v1",
"request_path": "/foo-service-v1",
"upstream_url": "http://foo-service.v1.local"
} Service version 2: {
"name": "foo-service.v2",
"request_path": "/foo-service-v2",
"upstream_url": "http://foo-service.v2.local"
} Api: {
"name": "foo-service",
"request_path": "/foo-service",
"upstream_url": "http://foo-service.local"
} Enable Plugin: {
"name": "header-redirect",
"header": "api-version",
"default": "v2",
"config.values[1]=v1:/foo-service-v1"
"config.values[2]=v2:/foo-service-v2"
} |
Beta Was this translation helpful? Give feedback.
-
I came across this issue when searching the message:
I am simply trying to have the same
Adding a second API with version
💩 Yes, I have to configure my plugins twice, but I would at least be able to have API domains with the same version. Is there any way to have two request hosts with the same request path? |
Beta Was this translation helpful? Give feedback.
-
Are there any plans for this feature request to be implemented? |
Beta Was this translation helpful? Give feedback.
-
https://apigee.com/about/blog/developer/common-misconceptions-about-api-versioning |
Beta Was this translation helpful? Give feedback.
-
It's quite common to version APIs to make sure that existing integrations continue to run while still making improvements, fixes and adding or removing functionality. This is done in a variety of ways including changing the URL, using custom headers, and leveraging the
accept
header. I believe Kong could help many API providers by allowing these conventions to map to the appropriate upstream services.Here's a few ideas on how it could work, of course this is a hotly debated topic and Kong should aim to support all of the use-cases that already exist in the wild. Some of the ideas are currently possible, specifically the URL pattern except you have to create an API for each version, and the others would be possible if you could map requests to upstream services based on headers (which I'll make a separate issue for but it would still require creating a new API for each version) In my opinion it's best to have Kong handle versioning APIs as it's own construct tied directly to the API being versioned.
How about some examples of expected functionality following common API versioning patterns? Let's say I have an API with two versions, 1 & 2, and I'd like the "default" to be version 2:
Request with the URL
http://api.example.com/1/endpoint
should send the request toexample-api.v1.local
Request with the URL
http://api.example.com/2/endpoint
should send the request toexample-api.v2.local
Request with the URL
http://api.example.com/324/endpoint
should probably return a 404.Request with the URL
http://api.example.com/endpoint
should send the request toexample-api.v2.local
Request with the header
api-version: 1
should send the request toexample-api.v1.local
Request with the header
api-version: 2
should send the request toexample-api.v2.local
Request with the header
api-version: 55
should send the request toexample-api.v2.local
Request without a
api-version
header should send the request toexample-api.v2.local
Request with the header
Accept: application/vnd.example.v1+json
should send the request toexample-api.v1.local
Request with the header
Accept: application/vnd.example.v2+json
should send the request toexample-api.v2.local
Request with the header
Accept: application/vnd.example.v55+json
should send the request toexample-api.v2.local
Request with out an
Accept
header should send the request toexample-api.v2.local
There are other considerations such as deprecation timetables (I only want the v1 to work for 6 months before it returns an error with information on how to upgrade to a newer version) and dealing with authentication to only allow certain consumers access to certain versions (paying users get access to beta versions) and much more I'm possibly leaving out. I'd like to get a discussion going here to think about the best way for Kong to support versioned APIs.
Thanks for reading!
Beta Was this translation helpful? Give feedback.
All reactions