kongfig icon indicating copy to clipboard operation
kongfig copied to clipboard

Support for 0.14.0 - services, routes, and other compatibility changes.

Open dgradl opened this issue 6 years ago • 26 comments

This provides support for Kong 0.13.0 Services and Routes. Specifically it was tested against 0.14.0. I tried to follow the patterns throughout the existing codebase. Unit and integration tests have been added and all tests are passing. I tried to allow for backwards compatibility, but there were some breaking API changes in 0.14.0 with certificates and I could not think of a way with the routes to deal with the compatibility change. Also, though I Initially replicated from API Plugins I removed the consumer based plugins thinking it wasn't supported but it is. I don't really have a use case for it so I don't have time immediately to go back and update that.

#132

dgradl avatar Sep 24 '18 01:09 dgradl

Ok I don't know why snyk is complaining - I've run it locally and it passes. Clicking details doesn't help because I do not have permissions.

dgradl avatar Sep 25 '18 12:09 dgradl

@dgarlitt snyk is a security tool it is scanning for potentially vulnerable packes konfig depends on. Here is the details although this is not specific to your branch.

screencapture-app-snyk-io-org-gavinlove-test-github-7d57c134-8f76-4551-a4d0-8c21aba82091-9420f67ac2c7457f0be6245079608dfda77cca8a-2018-09-25-13_26_36

gavinlove avatar Sep 25 '18 12:09 gavinlove

Yes I understand, I installed snyk and ran a snyk test locally and it does not find the vulnerabilities you've listed there, so that is what I find strange.

dgradl avatar Sep 25 '18 19:09 dgradl

@dgradl you can try removing the existing modules and lockfile rm -r node_modules yarn.lock and then reinstalling. That should update the deps that are reporting the vulns. Also, you can test locally via npm audit and that should provide you some quick fixes.

Edit: keep in mind you'll need to add the updated lockfile to the pr

cilindrox avatar Sep 28 '18 19:09 cilindrox

@dgradl I was looking at your branch Kong0140. When adding a new Route i see a PUT being made instead of POST. Kong document also says it is a POST. (https://docs.konghq.com/0.14.x/admin-api/#add-route) Can you please check on this.

mynameisgv avatar Sep 29 '18 21:09 mynameisgv

It is undocumented. Routes have no name so it's difficult to support update or remove in kongfig without some reference. I used a little bit of code that will convert a string "name" into a uuid and the put allows you to create routes with a given uuid.

https://github.com/Kong/kong/pull/3416

dgradl avatar Sep 29 '18 23:09 dgradl

FWIW, Routes are getting a name in 1.0 :)

If you see undocumented methods, we will backlog it and fix it on our side, but would also welcome a PR to our documentation!

Great job @dgradl!

thibaultcha avatar Sep 30 '18 00:09 thibaultcha

@dgradl I tried using the Branch for a simple service. I get PUT http://localhost:8001/routes/7c92cf1e-ee8d-39cc-85f8-355a3d6e4b86 { hosts: [ 'foo.com' ], paths: [], methods: [], service: { id: 'db7be8c1-7555-4349-aca4-292c6a659902' } } 405 Not Allowed { message: 'Method not allowed' } Error: Not Allowed {"message":"Method not allowed"}

Error: Not Allowed {"message":"Method not allowed"}

at /opt/Apps/Stash/kongfig/lib/core.js:394:45
at process._tickCallback (internal/process/next_tick.js:68:7)

Please take a look.

mynameisgv avatar Sep 30 '18 03:09 mynameisgv

Check your kong version. The integration tests validate that it works. I've also already started using this branch and migrated 50 of my apis to service/routes.

dgradl avatar Sep 30 '18 12:09 dgradl

@dgradl I use 0.33 enterprise edition. Even the integration test produce the same result.

FAIL test-integration/service.test.js (10.718s) ● Service routes › should add mockbin service with a route

Not Allowed
{"message":"Method not allowed"}

  392 |
  393 |                             if (!response.ok) {
> 394 |                                 var error = new Error(response.statusText + '\n' + content);
      |                                             ^
  395 |                                 error.response = response;
  396 |
  397 |                                 throw error;

  at lib/core.js:394:45

mynameisgv avatar Sep 30 '18 14:09 mynameisgv

Its tested against 0.14 community. As the PR indicates. I don't know what version of enterprise that Kong PR I referenced would be merged into. I certainly have no way to test against enterprise edition and I make no claim that this works with it.

dgradl avatar Sep 30 '18 18:09 dgradl

Hello @dgradl Thanks for your response. Actually i was wrong on the PUT support. Kong does not support a PUT (update/create route). It only does POST, PATCH , GET and Delete. 0.33 is same as 0.13.x . Even 0.13 does not support PUT. only 0.14 does.

I made some changes and got it working from 0.13. However since there is no way to find if a route already exists under a service, it keeps creating duplicate routes. For example if run the below definition 2 times it creates 2 routes under the service but only 1 services. The first run makes a POST CALL to create a service and the second one goes as PATCH and avoids duplicating. However when creating the route it always goes as POST and ends up duplicating. @thibaultcha Any way to overcome this problem. (0.13 and 0.33 ee)

{ "services": [{ "name": "mockbin", "ensure": "present", "attributes": { "url": "http://mockbin.com/test" }, "routes": [{ "name": "r1", "attributes": { "hosts": ["foo.com"], "paths": [], "methods": [] } }] }] }

mynameisgv avatar Oct 01 '18 05:10 mynameisgv

Yes I gave up on 0.13 support for that reason. Without a name or the put how can you associate the route in your yaml with the route in kong. You would have to match on hosts, paths, and methods. Except that any update you make would look like a new route. You could just delete all routes and replace every time. But this would result in your api being temporarily unavailable each time you run kongfig.

dgradl avatar Oct 01 '18 12:10 dgradl

any new about supporting routes and services?

rodriamaro avatar Nov 13 '18 13:11 rodriamaro

any news?

lightsaway avatar Nov 21 '18 09:11 lightsaway

We've been using this to automate k8s and Docker deployments: https://github.com/liyuntao/kong-init Needs a bit more spit and polish, but the maintainer has been awesome handling contributions.

cilindrox avatar Nov 21 '18 17:11 cilindrox

Anything on this? I'd really like to be able to use this.

mrgavinconway001 avatar Jan 10 '19 08:01 mrgavinconway001

I really struggled to get snyk to be happy with the dependencies as there were vulnerabilities before I even made updates. But I will take another stab at it soon. Though not sure if any PRs are getting merged on this repo.

On Thu, Jan 10, 2019, 3:45 AM mrgavinconway001 [email protected] wrote:

Anything on this? I'd really like to be able to use this.

— You are receiving this because you modified the open/close state. Reply to this email directly, view it on GitHub https://github.com/mybuilder/kongfig/pull/150#issuecomment-453015393, or mute the thread https://github.com/notifications/unsubscribe-auth/AAF2nXOonplTC6VssIs_6qPYVc59VeM7ks5vBv2wgaJpZM4W1-KC .

dgradl avatar Jan 11 '19 00:01 dgradl

I really struggled to get snyk to be happy with the dependencies as there were vulnerabilities before I even made updates. But I will take another stab at it soon.

Hi Dan, We are looking into Kong upgrade to 0.33 EE utilizing new data model but we stuck on kongfig not yet supporting it. Do you have an ETA on dependencies issue?

gudzenkov avatar Jan 22 '19 15:01 gudzenkov

Finally snyk is happy. Please approve.

dgradl avatar Mar 30 '19 20:03 dgradl

@dgradl does your PR fix service and route backups?

mrgavinconway001 avatar Mar 31 '19 09:03 mrgavinconway001

@dgradl I tested this branch and Looks like this version does not handle pagination. https://github.com/mybuilder/kongfig/pull/158

mynameisgv avatar Apr 03 '19 16:04 mynameisgv

pagination? service and route backups? Not really sure what you all mean. But like I don't really think anyone will ever merge this and I don't really care anymore. I've been using it to manage my Kong environment for the past 6 months.

dgradl avatar Apr 03 '19 18:04 dgradl

hey all, can we please get this merged in?

eraye1 avatar May 21 '19 21:05 eraye1

This one need to be merged

rendyfebry avatar Oct 16 '19 06:10 rendyfebry

Anyone fancy clicking that magic merge button?

mrgavinconway001 avatar Oct 16 '19 08:10 mrgavinconway001