This guide walks you through deploying and running Kong on Microsoft Azure Container Instances.
We will be using either Azure Database for PostgreSQL or Cosmos DB to store the gateway configuration.
Running Kong on Azure Container Instances
Azure Container Instances is a great way to run lightweight containers in a serverless fashion.
Running Kong on Azure Container Instances is super easy:
-
Provision a datastore
Provision the datastore that you want to use:
-
Open the Cloud Shell or Azure CLI
-
Run the migrations
$ az container create --name kong-migrations \ --resource-group kong-gateway \ --image kong:latest \ --restart-policy Never \ --environment-variables KONG_PG_HOST="<instance-name>.postgres.database.azure.com" \ KONG_PG_USER="<username>" \ KONG_PG_PASSWORD="<password>" \ --command-line "kong migrations bootstrap"
In this example, we are using a PostgreSQL database running on Azure Database for PostgreSQL.
Note for Kong < 0.15: with Kong versions below 0.15 (up to 0.14), use the
up
sub-command instead ofbootstrap
. -
Start Kong
$ az container create --name kong-gateway \ --dns-name-label kong-gateway \ --resource-group kong-gateway \ --image kong:latest \ --port 8000 8443 8001 8444 \ --environment-variables KONG_PG_HOST="<instance-name>.postgres.database.azure.com" \ KONG_PG_USER="<username>" \ KONG_PG_PASSWORD="<password>" \ KONG_PROXY_ACCESS_LOG="/dev/stdout" \ KONG_ADMIN_ACCESS_LOG="/dev/stdout" \ KONG_PROXY_ERROR_LOG="/dev/stderr" \ KONG_ADMIN_ERROR_LOG="/dev/stderr" \ KONG_ADMIN_LISTEN="0.0.0.0:8001, 0.0.0.0:8444 ssl"
The
8000
,8001
,8443
, and8444
will be forwarded to the container.Note: This will expose both the proxy and the Admin API on the default ports. This can have security implications. -
Use Kong
That’s it - You can now use Kong by browsing to
<dns-label>.westeurope.azurecontainer.io
.Quickly learn how to use Kong with the 5-minute Quickstart.