|
1 | 1 | # What is Kong?
|
2 | 2 |
|
3 |
| -Kong is a scalable, open source API Platform (also known as an API Gateway or API Middleware). Kong was originally built by [Kong Inc.](https://konghq.com) (formerly known as Mashape) to secure, manage, and extend over 15,000 Microservices for its API Marketplace, which generates billions of requests per month. |
| 3 | +Kong Gateway is the world’s most adopted API gateway. Lightweight, fast, and flexible, this open source gateway is built for hybrid and multi-cloud and optimized for microservices and distributed architectures. |
4 | 4 |
|
5 |
| -Under active development, Kong is now used in production at hundreds of organizations from startups, to large enterprises and governments including: The New York Times, Expedia, Healthcare.gov, The Guardian, Condè Nast, The University of Auckland, Ferrari, Rakuten, Cisco, SkyScanner, Yahoo! Japan, Giphy and so on. |
| 5 | +Built on this open source DNA, Kong’s unified cloud API platform helps organizations ranging from startups to Fortune 500 enterprises unleash developer productivity, build securely, and accelerate time to market. |
6 | 6 |
|
7 | 7 | Kong's official documentation can be found at [docs.konghq.com](https://docs.konghq.com/).
|
8 | 8 |
|
9 |
| -# How to use this image without a Database |
| 9 | +# How to use this image |
10 | 10 |
|
11 |
| -Kong 1.1 added the capability to run Kong without a database, using only in-memory storage for entities: we call this DB-less mode. When running Kong DB-less, the configuration of entities is done in a second configuration file, in YAML or JSON, using declarative configuration. |
12 |
| - |
13 |
| -```shell |
14 |
| -$ docker run -d --name kong \ |
15 |
| - -e "KONG_DATABASE=off" \ |
16 |
| - -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \ |
17 |
| - -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \ |
18 |
| - -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \ |
19 |
| - -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \ |
20 |
| - -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \ |
21 |
| - -p 8000:8000 \ |
22 |
| - -p 8443:8443 \ |
23 |
| - -p 8001:8001 \ |
24 |
| - -p 8444:8444 \ |
25 |
| - %%IMAGE%% |
26 |
| -``` |
27 |
| - |
28 |
| -Generate a skeleton configuration file to get you started |
29 |
| - |
30 |
| -```shell |
31 |
| -$ docker exec -it kong kong config init /home/kong/kong.yml |
32 |
| -$ docker exec -it kong cat /home/kong/kong.yml >> kong.yml |
33 |
| -``` |
34 |
| - |
35 |
| -Load a declarative configuration into a running Kong node via its Admin API using HTTPie |
36 |
| - |
37 |
| -```shell |
38 |
| -$ http :8001/config [email protected] |
39 |
| -``` |
40 |
| - |
41 |
| -**Note**: Not all Kong plugins are compatible with DB-less mode, since some of them by design require a central database coordination and/or dynamic creation of entities, see the doc for details at [DB-less and Declarative Configuration](https://docs.konghq.com/latest/db-less-and-declarative-config/) |
42 |
| - |
43 |
| -# How to use this image with a Database |
44 |
| - |
45 |
| -You can either use the official Cassandra/PostgreSQL containers, or use your own. |
46 |
| - |
47 |
| -## 1. Link Kong to either a Cassandra or PostgreSQL container |
48 |
| - |
49 |
| -It's up to you to decide which datastore between Cassandra or PostgreSQL you want to use, since Kong supports both. |
50 |
| - |
51 |
| -### Cassandra |
52 |
| - |
53 |
| -Start a Cassandra container by executing: |
54 |
| - |
55 |
| -```shell |
56 |
| -$ docker run -d --name kong-database \ |
57 |
| - -p 9042:9042 \ |
58 |
| - cassandra:3 |
59 |
| -``` |
60 |
| - |
61 |
| -### Postgres |
62 |
| - |
63 |
| -Start a PostgreSQL container by executing: |
64 |
| - |
65 |
| -```shell |
66 |
| -$ docker run -d --name kong-database \ |
67 |
| - -p 5432:5432 \ |
68 |
| - -e "POSTGRES_USER=kong" \ |
69 |
| - -e "POSTGRES_DB=kong" \ |
70 |
| - -e "POSTGRES_PASSWORD=kong" \ |
71 |
| - postgres:9.6 |
72 |
| -``` |
73 |
| - |
74 |
| -## 2. Prepare your database |
75 |
| - |
76 |
| -Run the database migrations with an ephemeral Kong container: |
77 |
| - |
78 |
| -```shell |
79 |
| -$ docker run --rm \ |
80 |
| - --link kong-database:kong-database \ |
81 |
| - -e "KONG_DATABASE=postgres" \ |
82 |
| - -e "KONG_PG_HOST=kong-database" \ |
83 |
| - -e "KONG_PG_USER=kong" \ |
84 |
| - -e "KONG_PG_PASSWORD=kong" \ |
85 |
| - -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ |
86 |
| - %%IMAGE%% kong migrations bootstrap |
87 |
| -``` |
88 |
| - |
89 |
| -In the above example, both Cassandra and PostgreSQL are configured, but you should update the `KONG_DATABASE` environment variable with either `cassandra` or `postgres`. |
90 |
| - |
91 |
| -**Note for Kong < 0.15**: with Kong versions below 0.15 (up to 0.14), use the `up` sub-command instead of `bootstrap`. Also note that with Kong < 0.15, migrations should never be run concurrently; only one Kong node should be performing migrations at a time. This limitation is lifted for Kong 0.15, 1.0, and above. |
92 |
| - |
93 |
| -### Start Kong |
94 |
| - |
95 |
| -Once the database has been started and prepared, we can start a Kong container and link it to the database container, and configuring the `KONG_DATABASE` environment variable with either `cassandra` or `postgres` depending on which database you decided to use: |
96 |
| - |
97 |
| -```shell |
98 |
| -$ docker run -d --name kong \ |
99 |
| - --link kong-database:kong-database \ |
100 |
| - -e "KONG_DATABASE=postgres" \ |
101 |
| - -e "KONG_PG_HOST=kong-database" \ |
102 |
| - -e "KONG_PG_PASSWORD=kong" \ |
103 |
| - -e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \ |
104 |
| - -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \ |
105 |
| - -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \ |
106 |
| - -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \ |
107 |
| - -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \ |
108 |
| - -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \ |
109 |
| - -p 8000:8000 \ |
110 |
| - -p 8443:8443 \ |
111 |
| - -p 8001:8001 \ |
112 |
| - -p 8444:8444 \ |
113 |
| - %%IMAGE%% |
114 |
| -``` |
115 |
| - |
116 |
| -If everything went well, and if you created your container with the default ports, Kong should be listening on your host's `8000` ([Proxy](https://docs.konghq.com/latest/configuration/#proxy_port)), `8443` ([Proxy SSL](https://docs.konghq.com/latest/configuration/#proxy_listen_ssl)), `8001` ([Admin API](https://docs.konghq.com/latest/configuration/#admin_listen)) and `8444` ([Admin API SSL](https://docs.konghq.com/latest/configuration/#admin_listen_ssl)) ports. |
117 |
| - |
118 |
| -You can read the docs at [docs.konghq.com](https://docs.konghq.com/) to learn more about Kong. |
119 |
| - |
120 |
| -## 3. Use Kong with a custom configuration (and a custom Cassandra/PostgreSQL cluster) |
121 |
| - |
122 |
| -You can override any property of the [Kong configuration file](https://docs.konghq.com/latest/configuration/) with environment variables. Just prepend any Kong configuration property with the `KONG_` prefix, for example: |
123 |
| - |
124 |
| -```shell |
125 |
| -$ docker run -d --name kong \ |
126 |
| - -e "KONG_DATABASE=postgres" \ |
127 |
| - -e "KONG_PG_HOST=kong-database" \ |
128 |
| - -e "KONG_LOG_LEVEL=info" \ |
129 |
| - -e "KONG_CUSTOM_PLUGINS=helloworld" \ |
130 |
| - -e "KONG_PG_HOST=1.1.1.1" \ |
131 |
| - -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \ |
132 |
| - -p 8000:8000 \ |
133 |
| - -p 8443:8443 \ |
134 |
| - -p 8001:8001 \ |
135 |
| - -p 8444:8444 \ |
136 |
| - %%IMAGE%% |
137 |
| -``` |
138 |
| - |
139 |
| -## Reload Kong in a running container |
140 |
| - |
141 |
| -If you change your custom configuration, reload Kong (without downtime) by running: |
142 |
| - |
143 |
| -```shell |
144 |
| -$ docker exec -it kong kong reload |
145 |
| -``` |
146 |
| - |
147 |
| -This will run the [`kong reload`](https://docs.konghq.com/latest/cli/#reload) command in your container. |
148 |
| - |
149 |
| -# Running Kong in read-only mode |
150 |
| - |
151 |
| -Starting with version `3.2.0` of Kong it is possible to run the container in read-only mode. To do so, mount a Docker volume to the locations where Kong needs to write data. The default configuration requires write access to `/tmp` and to the prefix path, as provided by the following example: |
152 |
| - |
153 |
| -```shell |
154 |
| -$ docker run --read-only -d --name kong \ |
155 |
| - -v "$(pwd)/declarative:/kong/declarative/" \ |
156 |
| - -v "$(pwd)/tmp_volume:/tmp" \ |
157 |
| - -v "$(pwd)/prefix_volume:/var/run/kong" \ |
158 |
| - -e "KONG_PREFIX=/var/run/kong" \ |
159 |
| - -e "KONG_DATABASE=off" \ |
160 |
| - -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \ |
161 |
| - -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \ |
162 |
| - -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \ |
163 |
| - -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \ |
164 |
| - -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \ |
165 |
| - -p 8000:8000 \ |
166 |
| - -p 8443:8443 \ |
167 |
| - -p 8001:8001 \ |
168 |
| - -p 8444:8444 \ |
169 |
| - %%IMAGE%% |
170 |
| -``` |
171 |
| - |
172 |
| -# Kubernetes Ingress |
173 |
| - |
174 |
| -Among the many deployment options [available](https://konghq.com/install), Kong also offers a [Kubernetes Ingress Controller](https://github.com/Kong/kubernetes-ingress-controller) ready to use in your K8s environment. |
| 11 | +Please refer to the [installation section](https://docs.konghq.com/gateway/latest/install/docker/#main) on our documentation website to learn how to use this image. |
0 commit comments