DEV Community

Pierangelo
Pierangelo

Posted on

4 4

kong api gateways with docker

KONG is a api gateway placed above the microservices aimed to managing the APIs and interactions external and internal with them in a more rational, efficient, safe and "easy" way, helping the developer in the separation between public and private APIs, improving their performance , facilitating monitoring etc ...

Some Characteristic:

  • Built on NGINX
  • For the most part written in LUA
  • Expandable via many Plugins
  • It supports two types of Datastores, which can also be used simultaneously (Postgres, cassandra)

Advantages:

  • Easy management of APIs in a Microservice architecture
  • helps in the separation between Public and Private APIs
  • allows to measure and possibly limit the use of these APIs.
  • Improves performance / through the use of caching etc ...)
  • Expandable through many plugins

The best way for move the fists step with KONG is using docker:

first, create and internal network for the dockers:

docker network create kong-net
Enter fullscreen mode Exit fullscreen mode

create a container for cassandra db:

docker run -d --name kong-cassandra-database \
              --network=kong-net \
              -p 9042:9042 \
              cassandra:3
Enter fullscreen mode Exit fullscreen mode

create a postgre sql container:

docker run -d --name kong-postgres-database \
              --network=kong-net \
              -p 5432:5432 \
              -e "POSTGRES_USER=kong" \
              -e "POSTGRES_DB=kong" \
              postgres:9.6
Enter fullscreen mode Exit fullscreen mode

create a migration:

docker run --rm \
    --network=kong-net \
    -e "KONG_DATABASE=postgres" \
    -e "KONG_PG_HOST=kong-postgres-database" \
    -e "KONG_CASSANDRA_CONTACT_POINTS=kong-postgres-database" \
    kong:latest kong migrations up
Enter fullscreen mode Exit fullscreen mode

create a kong container connected to the postgres and cassandra databases throught the internal network kong-net:

docker run -d --name kong \
    --network=kong-net \
    -e "KONG_DATABASE=postgres" \
    -e "KONG_PG_HOST=kong-postgres-database" \
    -e "KONG_CASSANDRA_CONTACT_POINTS=kong-cassandra-database" \
    -e "KONG_PROXY_ACCESS_LOG=/dev/stdout" \
    -e "KONG_ADMIN_ACCESS_LOG=/dev/stdout" \
    -e "KONG_PROXY_ERROR_LOG=/dev/stderr" \
    -e "KONG_ADMIN_ERROR_LOG=/dev/stderr" \
    -e "KONG_ADMIN_LISTEN=0.0.0.0:8001, 0.0.0.0:8444 ssl" \
    -p 8000:8000 \
    -p 8443:8443 \
    -p 8001:8001 \
    -p 8444:8444 \
    kong:latest
Enter fullscreen mode Exit fullscreen mode

check on url http://localhost:8001/

For more info, go on official web site here

Image of Timescale

🚀 pgai Vectorizer: SQLAlchemy and LiteLLM Make Vector Search Simple

We built pgai Vectorizer to simplify embedding management for AI applications—without needing a separate database or complex infrastructure. Since launch, developers have created over 3,000 vectorizers on Timescale Cloud, with many more self-hosted.

Read full post →

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up