DEV Community

Luis Rodrigues
Luis Rodrigues

Posted on

Creating a local development environment to Kong API with Docker

Alt Text
In this article let’s create a local development environment for Kong API. This environment is very useful to test our integration between our applications and Kong API Gateway.

If you want to know more about Kong API Management, check its documentation. Beyond API Gateway, Kong has other nice features to management our APIs.

We are going to use Docker to create our local development environment. Then, please install Docker tools in your local machine if you don’t have them yet.

Three docker containers are required to create a local development environment:

  • pantsel/konga: open source admin tool for Kong API Management.
  • kong: Kong API Management
  • postgres: Database for Kong API Management

Running Kong API Gateway

First, let’s create a docker network to each initiate docker container can communicate between themselves:

Start Postgres database to create a database for Kong API:

In this example we are using Postgres to creating a new database, however, Kong API Gateway supports Cassandra as its database as well.

Now, we need to run a data migration process to prepare Kong API database. Run the command below to start the data migration process:

Finally, start Kong API Gateway with the command below:

When the container is ready, two ports will be available for use in our machine (localhost):

Check Admin API documentation to know more about how to manage your APIs in Kong API Gateway.

Running Admin UI

Now that we have our Kong API Gateway ready, we can manage services, routes, and plugins for our APIs.

Those Kong API objects are managed with Admin API. For instance, the command below creates a new service to fictional “Product API” from the fictional address https://product-api.net”:

Sometimes, this task can be very challenging. Then, for testing purposes, we can manage our APIs in Kong API Gateway with Konga:

Konga is an open source project that allows us to manage Kong API Gateway with a UI. You can know more about the project here.

Run the command below to start the Konga container:

Konga will be started on port 1337 from your localhost. In the first access, the application will request to create a new user.

After creating the user, we need to create a new connection between Konga and Kong API Admin to manage our services:

Alt Text

Provide a name for the new connection, the IP address where Kong Admin API is running, and click on the “Create Connection” button. Then, you can see the Konga Dashboard.

Alt Text

If you had some issue with Kong Admin URL, try to provide the IP address from the Kong docker container. Execute the command below to get the IP address from the container:

It’s done! Now you can explore more Kong API Gateway in your local machine. Have happy findings with Kong API Gateway! :D

I hope that this can be helpful for you!

Oldest comments (0)