Skip to content
This repository was archived by the owner on Mar 18, 2024. It is now read-only.
/ kong Public archive

Declarative kong with environment variables

Notifications You must be signed in to change notification settings

webhood-io/kong

Repository files navigation

Kong declarative with env

Version Docker

Kong with ability to reference environment variables in declarative configuration file.

Why?

Kong declarative configuration doesn't support environment variables interpolation ie. refencing an environment variable to be substituted at runtime.

How?

This image is based on the official Kong image and uses the same Dockerfile used to build the official one, but with a custom entrypoint that does the interpolation.

All strings that start with _FILE will be replaced by the value of the environment variable with the same name.

Getting Started

Create a config file with environment variables to be interpolated. For example:

with env

SECRET=SuperSecretValue

and file kong.yml

secret: SECRET_FILE

will be interpolated to

secret: SuperSecretValue

Configure

example.yaml

---
_format_version: '1.1'
consumers:
  - username: anon
    keyauth_credentials:
      - key: ANON_KEY_FILE

Remember to set the environment variable to be interpolated: ANON_KEY

docker-compose.yml

 services:
  kong:
    container_name: webhood-kong
    image: ghcr.io/webhood-io/kong:main
    restart: unless-stopped
    environment:
      ANON_KEY: ${ANON_KEY}
      WEBHOOD_CONFIG: /tmp/kong.yml
    volumes:
      - ./kong.yml.example:/tmp/kong.yml:ro
docker up -d

TODO / not supported

  • Support same base images than the official image. Now image is based on Debian (alpine, centos)
  • Support other vars than what are supported by Webhood

About

Declarative kong with environment variables

Resources

Stars

Watchers

Forks

Packages