Search code examples
kuberneteskongkong-ingress

Kong reboot in DB-less mode


Playing around with Kong in DB-less mode in a docker container. Trying to figure out if we can use it as a gateway for the company I work for. I currently mount a local folder onto my docker container and pass the path to the kong.yaml file to kong when it starts. When I need to update the configuration, I do a POST to the /config endpoint.

All good so far.

However, my concern is, how I am supposed to handle a Kong restart? The configuration I have will be generated in a separate micro-service from a PostGre database.

Kong will be running as an Ingress controller in our Kubernetes cluster. One thing I could do is expose an endpoint that generates a kong.yml config file based on my data in PostGre. Kong could hit that on start up. I think I can make it a part of its start command.

Anyway, this seems like perhaps a bit of a hack. I was wondering, are there are any best practices around this. I'm sure other people have faced this problem before :-)

Thanks!


Solution

  • Answer

    Configuring Kong on Kubernetes is done through Kubernetes native resources (e.g. Ingress) and Kong Custom Resources (e.g. KongConsumer, KongPlugin, KongIngress).

    The Kong Ingress Controller will make all necessary changes based on changes to those resources through the Kubernetes API Server.

    Additional Info

    I highly recommend going through these guides. They are comprehensive and highly educational.

    Make sure to keep an eye on the logs coming out of the Kong Ingress Controller pod because this will tell you whether it has successfully reconciled changes based on those resources or not.

    Also feel free to take a look at this project where we manage Kong CRs through an on-cluster REST API Microservice.