-
Notifications
You must be signed in to change notification settings - Fork 4.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[community feedback requested] A new way to install and configure Kong #2355
Comments
We could still have kong_cassandra_contact_points 10.0.0.1,10.0.0.2;
kong_cassandra_keyspace kong;
kong_cassandra_user kong_user;
kong_cassandra_password password; And a location: location / {
include kong.conf;
# include kong-debug.conf;
# include kong-production.conf;
kong_serve_proxy;
} |
Will the suggested changes make it notably easier, or harder, to discover, install, configure, upgrade, and remove plugins (Kong CE plugins, Kong Enterprise plugins, Community-supported plugins, custom plugins built and used by a single entity, etc)? |
@bungle Good idea! Definitely a nice side-effect that we can take advantage of. |
@coopr I don't think those two topic (the one covered in this issue and external plugins) relate very much. The idea would be to have a set of chosen plugins (living in other repositories) being fetched and bundled when the |
Looks very nice. May a suggest it should be an easy way to specify the configuration when running Kong with Docker? something like |
Regarding the nginx config being harder to grasp, this is something that devs are used to coming over. With regard to this project specifically, a kong user is likely to be getting into nginx configuration at some point anyway as their demands on kong grow. This only makes the issue of learning nginx syntax come quicker. |
I don't know lua and I didn't 'get' the magic that was happening inside Kong when I needed to add our strong SSL configuration. I'm sure it was possible, but it was easier to deal with vanilla nginx and proxy traffic to Kong. The above approach reads as becoming more nginx-orientated and removing some of the magic that would otherwise frustrate those (like me) already familiar with nginx. I could see this approach as shifting the responsibility during the long-Kong (the post-honeymoon period where you've sold your team on Kong) from Kong and Lua and deep internals to familiar and trusted Nginx. I hope that makes sense.
I'd be happy for Kong to be the nginx provider if I can be certain it's keeping up with security patches. Unless I read that incorrectly. |
@peterbsmith2
Definitely 👍 @lsh-0 Thanks for the feedback!
Yes you did read that correctly. Good point. At the same time, it is worth noting that OpenResty is our Nginx provider (Kong > OpenResty > Nginx), and as such, Kong keeps up with security patches as much as OpenResty does. OpenResty generally does a good job at staying up to date in terms of security patches. At the same time, the good news is that since we can also add custom patches to the Nginx core, we can provide a release before OpenResty does so, if it ever happens that it is lagging behind (which I doubt :) ). |
My opinion FWIW: Overall bringing Kong closer to openresty > nginx patterns into kong by way of using the nginx config + making it a better practice to make Kong vs install via package sound like simpler way to develop Kong, and a more flexible way to use/configure/deploy it in more environments |
I like this direction overall. If Kong were more "nginx-like" we could use regular Ansible scripts instead of having to maintain custom module + playbook. Also, there's wealth of documentation for nginx and experienced developers available. Could you also explain how upgrading is done with this model? Download new Kong release, make install and then just start that nginx with your config? I've understood that migrations are run "automatically" when upon startup Kong sees that database has older schema. How does this affect Kong clustering and its use of serf? |
@samrose @jussiarpalahti Thanks for taking the time to read this and share your thoughts.
Eventually, the migrations will keep being part of the CLI. Said CLI does not start and stop Kong directly anymore, but provides an utility belt (migrations, add-api, remove-api, version...). To upgrade, I hope we can somewhat follow the same steps as the Nginx binary upgrade path: download Kong, install, run
Serf is currently being removed from Kong. That is the main blocker as of today for implementing this. Clustering will really be stateless, and events will be propagated with some database polling. More on that very shortly :) |
Sorry but I $ wget http://getkong.org/download/kong-0.12.0.tar.gz ---> not found. |
@hungpt91 This issue is to discuss the idea presented above, none of this exists as of today. |
@thibaultcha, upgrade model sounds good. re:clustering: interesting... :) |
indeed, that's why I proposed #3010. Comparing our nginx conf to the new templates was one of the most time consuming task when preparing upgrades. We mitigated by patching the official template instead of having a separate version, but that's hardly a clean solution. The above-proposed process seems like a much more elegant solution.
On the other hand, it makes it easier for nginx users to grasp kong integration. |
Problem ------- Kong ships with an NGINX template which is rendered when Kong starts. There exists no mechanisms to add/update any NGINX directive to the `nginx.conf` used to run Kong. To change or add any directive, user has to use a custom NGINX template which has to be synced with Kong for a release which introduces changes to Kong's template. Including options in `kong.conf` to configure NGINX directives is not a good solution since the list will be endless. This problem can be seen in #3010, #3323 and #3382. Solution -------- There needs to be a flexible way to specify any NGINX directive via Kong's config file without Kong needing to maintain a list of all NGINX directives. While a clean and ideal solution would be #2355, this commit adopts a simpler as discussed like the one proposed in #2675. NGINX directives can be specified using config variables with prefixes, which help determine the block in which to place a directive. eg: `nginx_proxy_add_header=Header-Name header-value` will add a `add_header Header-Name header-value;` directive in the proxy server block of Kong. `nginx_http_lua_shared_dict=custom_cache 2k` will add a a `lua_shared_dict custom_cache 2k;` directive to HTTP block of Kong.s
Problem ------- Kong ships with an NGINX template which is rendered when Kong starts. There exists no mechanisms to add/update arbitrary NGINX directives to the `nginx.conf` used to run Kong. To change or add any directive, user has to use a custom NGINX template which has to be synced with Kong for a release which introduces changes to Kong's template. Including options in `kong.conf` to configure NGINX directives is not a good solution since the list will be endless. This problem can be seen in #3010, #3323, and #3382. Proposed Solution ----------------- Proposed in #3382: There needs to be a flexible way to specify any NGINX directive via Kong's config file without Kong needing to maintain a list of all NGINX directives. While a clean and ideal solution would be #2355, this commit adopts a simpler approach as described in #3382, and keeps solutions similar to the one proposed in #2675 possible (by way of injecting an `include` directive). NGINX directives can be specified using config variables with prefixes, which helps determine the block in which to place a directive. E.g.: * `nginx_proxy_add_header=Header-Name header-value` will add a `add_header Header-Name header-value;` directive in the proxy `server` block of Kong. * `nginx_http_lua_shared_dict=custom_cache 2k` will add a `lua_shared_dict custom_cache 2k;` directive to `http` block of Kong.
This may represent a long-term plan, but as we have decided to improve on |
Summary
a. Installing
b. Configuring
1. Problem
Today's Kong can be quite un-intuitive and painful to both install and configure:
kong.conf
, andnginx.conf
.stdout
logging or non-daemon mode harder for containers setups.Source installs are quite common because they allow building Nginx with custom flags (and custom Nginx C modules), and custom Nginx configurations are even more common, because
kong.conf
does not (and should not because it is not "scalable") support each and every Nginx directive.2. Proposed new approach
a. Installing
Release Kong as an archive like
kong-0.12.0.tar.gz
containing:The installation process for Kong would consist of:
And that's it. Let's walk through the steps and what they achieved here:
Here, we just downloaded the latest release archive and extracted it. Such an archive should be PGP signed by the core Kong contributors for each release, ensuring users get what they want.
This is a
configure
script that wraps the OpenResty one (which installs LuaJIT + Nginx). It allows any OpenResty flag, and thus, any Nginx flag as well. It also adds the flags required by Kong automatically, (such as--with-pcre-jit
or--with-http_realip_module
) so users don't have to worry about it. One can compile Kong like so:We now allow Kong users to very easily customize the underlying Nginx instance running Kong, without compromising the minimum flags required by Kong.
This step will also take care of installing LuaRocks with the newly compiled LuaJIT (from the OpenResty
./configure
).Just compilation and installation steps. During installation, we copy the Kong Lua sources into the prefix's
lualib
(the place where Lua modules required from an OpenResty installation should go to). LuaRocks mostly is bundled for futurekong install [plugin]
features relying on it.b. Configuring
Let's see what the previous installation step actually installed:
Here, most of those files come from a regular OpenResty installation, but
luarocks
andnginx.conf
are added by Kong (among other files inlualib
andbin
like the Lua sources and the CLI, but not detailed here).What interests us here is the
nginx.conf
file, because it would be the only configuration file needed. That's right, nokong.conf
.Here is what such a
nginx.conf
file might look like, but take it with a grain of salt as it is a very early, draft document:This is achieved through a custom Nginx C module, that is transparent to the user because it is added under the hood by the Kong install phase (shipped in
kong-0.12.0.tar.gz
and automatically added to./configure
flags).Thus, we allow any user to easily customize their Nginx instance to do anything they'd like:
server
blockThis is very beneficial in the sense that users now don't need to maintain two configuration files. The Kong C module will try to avoid as many required changes to the Nginx configuration as possible (like manually adding
lua_shared_dict
directives, and so).Kong is now not started from its CLI anymore, but directly from Nginx, as in:
3. Pros and Cons
Going down this road has numeral benefits for users, power-users and contributors. Here is a non-exhaustive list:
daemon off;
,error_log stdout;
...). This could potentially mean that Kong could come back on Heroku as well.There are a few losses as well that I will try to list objectively:
nginx.conf
).Those lists should be maintained and updated (edit this issue).
4. Community Feedback
Would love community feedback on this one! Thoughts? Concerns? Better ideas? Please comment and share!
The text was updated successfully, but these errors were encountered: