I want to deploy Kong API gateway (in db mode) in my apps. So I thought of two approaches.
Use kubectl and helm to install kong in the cluster. But this seemed odd because I won’t be able to use a repository and also I wasn’t sure how would my external domain map to the internal IP. So I didn’t went ahead with this.
Create a repo with a Dockerfile that is deployed using Qovery. This Dockerfile would contain kong and relevant details. This seems to make more sense.
At it’s face, the Kong App is unable to access the postgres db. When I searched online, some people talk about creating a docker network (ex: this SO post, while others are able to solve by ensuring that their pg db is started and ready to accept connections when kong is initialised. In my case, the db is already running and I can not update docker network.
Any ideas on what to do here? Or is there any other API Gateway that you suggest? I have tried KrakenD and it doesn’t fit by needs. I also searched on AWS API Gateway but it seems like networking/connecting b/w Qovery apps and the gateway might be tricky.
I will respond to this question You can take a look at this guide I made which is using an NGINX instance as an API gateway.
Now coming back to your original question, I notice the following:
You are running the migration during the build of the container
RUN kong migrations bootstrap -v
It will not work since the build nodes are running on Qovery instances without access to your infrastructure. So, I recommend running this command inside your Entrypoint file /docker-entrypoint.sh. Then it will be executed at the runtime (on your infrastructure) instead of build time (our infrastructure).
I think this may solve your issue
One more thing, I would recommend not exposing your database publicly.
Thanks for the tip on security. I initially thought this has something to do with public/private access because I have faced similar issues in past. Ref: Unable to access private postgres - #5 by r4881t I will try this again after the issue is resolved and update you.
@rophilogene - As a followup question, Kong listens on many ports - 8000 8443 8001 8444. I have mapped 8000 - 443 in the app section. Is there a way to map other ports as well? I will be using a CloudFlare Zero Trust to set up access control on the other ports.
My apologies, I meant with public access. I want to access these ports on the deployed URL like sub.domain.com:8081. When I set them to public, it takes 443 as the default port.
Unfortunately, you can’t change the exposed port, but we plan to add it. Is it a hard requirement for your use case? Can you explain why you would prefer exposing your service with 8081 instead of 443?
Hi @rophilogene , the requirement comes because of how [Kong]( is built. Kong exposes the API Gateway (for public access) on 8080 (regular http) and 8333 (ssl http). It has an Admin API that it exposes on port 8081. People typically use a UI (ex:: King) to visually make changes to Kong configs.
Hope that clarifies the use case.
–
Now in order to bypass the current limitation, I created a simple nodejs proxy service and deployed it as an application in my environment. This proxy service is set to use the “kong-app-internal-host:8081” as the upstream application.
So now, I can use the URL exposed by Qovery “PHPNET - Nom de domaine something.fr en parking” and make my admin commands. Since this is public, it’s no good. So I have mapped this to a custom domain “admin.mysite.com” and used CloudFlare Access Rules to specify only certain emails to get this. ow this is working when someone tries to use “admin.mysite.com” but the original url “something.fr” is still accessible. so I am figuring out how to achieve this.