Get Kong
Kong Gateway is a lightweight, fast, and flexible cloud-native API gateway. Kong Gateway sits in front of your service applications, dynamically controlling, analyzing, and routing requests and responses. Kong Gateway implements your API traffic policies by using a flexible, low-code, plug-in based approach.
This tutorial will help you get started with Kong Gateway by setting up a local installation and walking through some common API management tasks.
This page will walk you through running Kong Gateway and verifying it with the Admin API. Once complete, the following tasks can be performed to complete the tutorial:
- Understanding and configuring Services and Routes
- Configuring Rate Limiting to protect upstream Services
- Increase system performance with Proxy Caching
- Load Balancing for horizontal Service scaling
- Protecting Services with Key Authentication
Prerequisites
- Docker is used to run Kong Gateway and supporting database locally
- curl is used to send requests to Kong Gateway.
curl
is pre-installed on most systems - jq is used to process JSON responses on the command line. While useful, this tool is not necessary to complete the tasks of this tutorial. If you wish to proceed without
jq
, modify the commands to removejq
processing.
Get Kong
For the purposes of this tutorial, a quickstart
script is provided to quickly run Kong Gateway and its supporting database. This script uses Docker to run Kong Gateway and a PostgreSQL database as the backing database.
Run Kong Gateway with the
quickstart
script:curl -Ls https://get.konghq.com/quickstart | bash -s
This script runs Docker containers for Kong Gateway and the supporting PostgreSQL database. The script also creates a Docker network for those containers to communicate over. Finally, the database is initialized with the appropriate migration steps, and once the Kong Gateway is ready, you will see the following message:
✔ Kong is ready!
Verify that Kong Gateway is running:
Kong Gateway serves an Admin API on the default port
8001
. The Admin API can be used for both querying and controlling the state of Kong Gateway. The following command will query the Admin API, fetching the headers only:curl --head localhost:8001
If Kong Gateway is running properly, it will respond with a
200
HTTP code, similar to the following:HTTP/1.1 200 OK
Date: Mon, 22 Aug 2022 19:25:49 GMT
Content-Type: application/json; charset=utf-8
Connection: keep-alive
Access-Control-Allow-Origin: *
Content-Length: 11063
X-Kong-Admin-Latency: 6
Server: kong/3.0.x
Evaluate the Kong Gateway configuration:
The root route of the Admin API provides important information about the running Kong Gateway including networking, security, and plugin information. The full configuration is provided in the
.configuration
key of the returned JSON document.curl -s localhost:8001 | jq '.configuration'
You should receive a large JSON response with Kong Gateway configuration information.
Every step in this tutorial requires a running Kong Gateway, so leave everything running and proceed to the next steps in this tutorial.
Next Services and Routes