Skip to content
This repository was archived by the owner on Feb 12, 2022. It is now read-only.

Commit 6d87c68

Browse files
authored
Kong 1.0 (#25)
* Migrate to Kong 1.0 * Database seed for Kong 1.0 Admin API proxy * Update Kong config to set DB & listener values correctly (match sample from buildpack) * Update database seed for Kong 1.0 Admin API proxy (rc3) * Specify Heroku stack * Import updated spec helpers from upstream Kong * Revise plugin tests to follow Kong 1.0 test style * Avoid Cassandra confusion during local testing * Use Heroku CI in-dyno database * Update spec helpers with source from Kong 1.0 * Update kong & busted bins with source from Kong 1.0 * Update tests conf to include custom plugins * Updating integration tests for Kong 1.0 * 📚 update docs for Kong 1.0.0 * Update pre-release buildpack branch to master
1 parent e15cb72 commit 6d87c68

File tree

13 files changed

+374
-170
lines changed

13 files changed

+374
-170
lines changed

.profile.local

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export PATH="~/.luarocks/bin:${PATH:-}"
22
export LUA_PATH="./lib/?.lua;./lib/?/init.lua;;"
33
export LUA_CPATH="./lib/?.so;;"
4+
export KONG_TEST_DATABASE=postgres

ADMIN.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,19 +45,19 @@ curl http://localhost:8001/services/ -i -X POST \
4545
curl http://localhost:8001/plugins/ -i -X POST \
4646
--data 'name=request-size-limiting' \
4747
--data "config.allowed_payload_size=8" \
48-
--data "service_id=$SERVICE_ID"
48+
--data "service.id=$SERVICE_ID"
4949
curl http://localhost:8001/plugins/ -i -X POST \
5050
--data 'name=rate-limiting' \
5151
--data "config.minute=5" \
52-
--data "service_id=$SERVICE_ID"
52+
--data "service.id=$SERVICE_ID"
5353
curl http://localhost:8001/plugins/ -i -X POST \
5454
--data 'name=key-auth' \
5555
--data "config.hide_credentials=true" \
56-
--data "service_id=$SERVICE_ID"
56+
--data "service.id=$SERVICE_ID"
5757
curl http://localhost:8001/plugins/ -i -X POST \
5858
--data 'name=acl' \
5959
--data "config.whitelist=kong-admin" \
60-
--data "service_id=$SERVICE_ID"
60+
--data "service.id=$SERVICE_ID"
6161
curl http://localhost:8001/routes/ -i -X POST \
6262
--data 'paths[]=/kong-admin' \
6363
--data 'protocols[]=https' \

README.md

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,6 @@
11
Kong as a Heroku app
22
====================
3-
Deploy [Kong 0.14](https://konghq.com/kong-community-edition/) clusters to Heroku Common Runtime and Private Spaces using the [Kong buildpack](https://github.com/heroku/heroku-buildpack-kong).
4-
5-
🥚 Try the [Kong 1.0 release candidate](https://github.com/heroku/heroku-kong/tree/kong-1.0) with the `kong-1.0` branch.
3+
Deploy [Kong 1.0](https://konghq.com/blog/kong-1-0-ga/) clusters to Heroku Common Runtime and Private Spaces using the [Kong buildpack](https://github.com/heroku/heroku-buildpack-kong/).
64

75
**Upgrading from an earlier version?** See [Upgrade Guide](#user-content-upgrade-guide).
86

@@ -143,9 +141,13 @@ See these examples of [Using Terraform with Heroku](https://devcenter.heroku.com
143141

144142
#### The buildpack
145143

146-
[Buildpack v6.0.0](https://github.com/heroku/heroku-buildpack-kong/releases) supports rapid deployments using a
144+
[Buildpack v6.0.0](https://github.com/heroku/heroku-buildpack-kong/releases) supports rapid deployments using a
147145
pre-compiled Kong binary. A pre-existing, customized app may require changes continue functioning, if the app explicitly uses the `/app/.heroku` directory prefix.
148146

147+
[Buildpack v7.0.0-rc\*](https://github.com/heroku/heroku-buildpack-kong/releases) supports Kong 1.0 release candidates. The "rc" releases only support upgrading from Kong 0.14, not earlier versions or other release candidates.
148+
149+
[Buildpack v7.0.0](https://github.com/heroku/heroku-buildpack-kong/releases) supports Kong 1.0.
150+
149151
▶️ See [UPGRADING the buildpack](https://github.com/heroku/heroku-buildpack-kong/blob/master/UPGRADING.md).
150152

151153
#### Kong
@@ -161,6 +163,8 @@ Then, take into account these facts about how this Kong on Heroku app works:
161163
1. [perform the upgrade](https://github.com/Kong/kong/blob/master/UPGRADE.md)
162164
1. allow release process to run
163165
1. finally restart to the original formation size `heroku ps:scale web=$PREVIOUS_SIZE`
166+
* once Kong 1.0 is successfully deployed, execute: `
167+
heroku run "kong migrations finish --conf /app/config/kong.conf"`
164168

165169
🏥 Please [open an issue](https://github.com/heroku/heroku-kong/issues), if you encounter problems or have feedback about this process.
166170

@@ -397,7 +401,7 @@ heroku info
397401

398402
1. Ensure [requirements](#user-content-requirements) are met
399403
1. Create the Postgres user & databases:
400-
404+
401405
```bash
402406
createuser --pwprompt kong
403407
# set the password "kong"
@@ -413,7 +417,7 @@ heroku info
413417
bin/start
414418
```
415419

416-
* Logs in `/usr/local/var/kong/logs/`
420+
* Logs in `/usr/local/var/kong/logs/`
417421
* Prefix is `/usr/local/var/kong` for commands like:
418422
* `kong health -p /usr/local/var/kong`
419423
* `kong stop -p /usr/local/var/kong`

app.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
"website": "https://getkong.org/",
1313
"repository": "https://github.com/heroku/heroku-kong.git",
1414
"success_url": "https://github.com/heroku/heroku-kong/blob/master/README.md#user-content-usage",
15+
"stack": "heroku-18",
1516
"buildpacks": [{
1617
"url": "https://github.com/heroku/heroku-buildpack-kong.git"
1718
}],
@@ -23,5 +24,10 @@
2324
"description": "A secret key for accessing Kong's Admin API via public proxy at /kong-admin",
2425
"generator": "secret"
2526
}
27+
},
28+
"environments": {
29+
"test": {
30+
"addons": ["heroku-postgresql:in-dyno"]
31+
}
2632
}
2733
}

bin/busted

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ if not os.getenv("KONG_BUSTED_RESPAWNED") then
5959
os.exit(rc)
6060
end
6161

62-
require "luarocks.loader"
62+
pcall(require, "luarocks.loader")
6363

6464
require("kong.globalpatches")({
6565
cli = true,

bin/kong

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env resty
22

3-
require "luarocks.loader"
3+
pcall(require, "luarocks.loader")
44

5-
package.path = "?/init.lua;"..package.path
5+
package.path = (os.getenv("KONG_LUA_PATH_OVERRIDE") or "") .. "./?.lua;./?/init.lua;" .. package.path
66

7-
require("kong.cmd")(arg)
7+
require("kong.cmd.init")(arg)

bin/prerelease

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,5 @@ if [ -n "$admin_key" ]
2121
then
2222
echo "Setting Admin API key to value of KONG_HEROKU_ADMIN_KEY"
2323
# This `id` matches the "kong-admin" keyauth_credentials record contained in "config/pg-heroku-admin.dump"
24-
psql "$DATABASE_URL" -c "UPDATE keyauth_credentials SET key='${admin_key}' WHERE id='ac8af1d3-377a-41ae-9fd5-dbf98c599c5c';"
24+
psql "$DATABASE_URL" -c "UPDATE keyauth_credentials SET key='${admin_key}' WHERE id='8e4b1774-0b0f-463f-bab1-6468d1fdc5c3';"
2525
fi

config/kong.conf.etlua

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,9 @@ plugins = bundled,hello-world-header,ndfd-xml-as-json
9797
# NGINX
9898
#------------------------------------------------------------------------------
9999

100-
proxy_listen = 0.0.0.0:<%= proxy_port %>
100+
# Heroku Kong expects listeners to be set via environment variables
101+
# such as `KONG_PROXY_LISTEN`
102+
proxy_listen = <%= proxy_listen %>
101103
# Address and port on which Kong will accept
102104
# HTTP requests.
103105
# This is the public-facing entrypoint of
@@ -106,17 +108,18 @@ proxy_listen = 0.0.0.0:<%= proxy_port %>
106108
# Note: See http://nginx.org/en/docs/http/ngx_http_core_module.html#listen for
107109
# a description of the accepted formats for this and other *_listen values.
108110

109-
proxy_listen_ssl = 0.0.0.0:<%= proxy_ssl_port %>
111+
#proxy_listen_ssl = <%= proxy_listen_ssl %>
110112
# Address and port on which Kong will accept
111113
# HTTPS requests if `ssl` is enabled.
112114

113-
admin_listen = 0.0.0.0:<%= admin_api_port %>
115+
admin_listen = <%= admin_listen %>
114116
# Address and port on which Kong will expose
115117
# an entrypoint to the Admin API.
116118
# This API lets you configure and manage Kong,
117119
# and should be kept private and secured.
118120

119-
#admin_listen_ssl = 0.0.0.0:8444 # Address and port on which Kong will accept
121+
#admin_listen_ssl = <%= admin_listen_ssl %>
122+
# Address and port on which Kong will accept
120123
# HTTPS requests to the admin API, if
121124
# `admin_ssl` is enabled.
122125

@@ -331,11 +334,14 @@ database = postgres # Determines which of PostgreSQL or Cassandra
331334
# Accepted values are `postgres` and
332335
# `cassandra`.
333336

334-
pg_host = <%= pg_host %>
335-
pg_port = <%= pg_port %>
336-
pg_user = <%= pg_user %>
337-
pg_password = <%= pg_password %>
338-
pg_database = <%= pg_dbname %>
337+
# Heroku Kong expects listeners to be set via environment variables
338+
# such as `KONG_PG_HOST` which is generated by config/kong-12f.lua script
339+
# from Heroku Postgres' `DATABASE_URL` value.
340+
pg_host = <%= pg_host %>
341+
pg_port = <%= pg_port %>
342+
pg_user = <%= pg_user %>
343+
pg_password = <%= pg_password %>
344+
pg_database = <%= pg_database %>
339345

340346
pg_ssl = on # Toggles client-server TLS connections
341347
# between Kong and PostgreSQL.

config/pg-heroku-admin.dump

-2.15 KB
Binary file not shown.

0 commit comments

Comments
 (0)