Haufe-Lexware / wicked.haufe.io

An API Management system based on Mashape Kong
http://wicked.haufe.io
Other
121 stars 37 forks source link

Isolate the Portal to use with my own Kong Deployment #271

Open IuriGarcia opened 4 years ago

IuriGarcia commented 4 years ago

Hello everyone,

I am still looking around to manage to just use the api portal deployment of helm charts and dependencies in order to make it run with my kong deployment. But i will already ask for tips to help me out.

already thankful.

DonMartin76 commented 4 years ago

In principle, it should be possible to make wicked work with an existing Kong deployment (of a suitable version, i.e. 0.14.1). BUT: wicked assumes it is allowed to take over Kong completely and will rigorously delete anything from Kong which it does not deem belong in there. I.e., any services or route definitions which were manually added will be deleted automatically.

If this still is interesting to you, I can dig out what kind of configuration would need to be done to make wicked talk to an existing Kong installation.

IuriGarcia commented 4 years ago

Hm, in the first place, ty so much for your time! That's an important info, since i am using Kong Ingress in a K8s and do often deploy customized APIs and CRDs.

I've been testing the portal and it is just great, and i am looking to use it as my API portal. Well, i will discuss with the team and be back soon, ty again Mr!

DonMartin76 commented 4 years ago

What you can/should do in that case is probably to have a separate API gateway for your publicly available APIs, and keep the internal/private ones in the instance you already have. Depending on your setup, you can still re-use the Postgres instance (in a separate database on the same instance) if that makes it easier, but still let the wicked/Kong Postgres instance be the same as the one you are using.

andrevtg commented 4 years ago

Me and Iuri are still trying to figure this out. Kong Ingress Controller is a db-less Kong instance in itself. There is no postgres around, it uses CRD objects instead (CRDs are synced to Kong admin automagically).

This is a Kong deployment style that is gaining lot of traction lately. We are wondering if Wicked could be adapted for it. Looking at its architecture it should be the case to focus on "Kong Adapter" and "Portal API" components.

https://github.com/Haufe-Lexware/wicked.haufe.io/blob/master/doc/images/deployment-architecture.png

We are willing to put some energy on this. What do you think?

DonMartin76 commented 4 years ago

Sounds intriguing. I have not yet looked at the Kong Ingress controller in detail, so I can't quite tell if this would work, or how much effort it would be.

Here are some things to check out, and I am throwing in some ideas which might be leading somewhere:

The biggest caveat which I see is how wicked/Kong currently deals with OAuth2 - which is a core part of how the portal works. The API (portal-api) is also accessed via Kong normally, and this will probably require some fiddling to make it work.

andrevtg commented 4 years ago

That sounds promising. The Kong Admin API still works, but it's read-only. That is why we can still plug Konga (for example) to Kong Ingress Controller (the API endpoint is still there). All objects created by CRDs show up (r/o) in Kong Admin API eventually (background syncing).

OAuth should work too, if it is based on a Kong plugin.

DonMartin76 commented 4 years ago

OAuth is based on the (pretty shitty) Kong oauth2 plugin, yes. But I have plans to implement a more direct approach which just injects credentials via the /oauth2_tokens endpoint, as the actual oauth2 implementation only has very weird support for the actual flows. You end up implementing them yourself anyway (wicked.auth), and Kong 1.0+ removed support for querying for the refresh token.

So this could be an issue - the access token management for OAuth2.

IuriGarcia commented 4 years ago

So, looking at the architecture and part of the schemas in the database , it seems that PortalAPI is not accessing any Kong schema but isn't PortalAPI suposed to manage the same data that Kong is managing? I want to confirm if Portal Api and Kong are accessing the same schemas, eventually ,or if it is never happening.

DonMartin76 commented 4 years ago

wicked and Kong are never accessing the same schema in the database. wicked only works with the API of Kong, "remote controlling" Kong via the 8001 port administration API. In the end, wicked has all the data, and configures Kong so that it reflects the state of the database of Kong. In principle, you could delete the Kong schema entirely, start Kong, and restart the Kong Adapter container, and wicked would recreate the entire Kong schema via the administration API again.

The only thing which would go missing are current access tokens (and refresh tokens of course).