This project assemble instructions to deploy Kong gateway in Tsuru Paas
We are using Tsuru as our Platform as a Service software (Paas), and we decided to deploy Kong in Tsuru in order to manage APIs and Microservices.
Notes:
- We are using Tsuru 1.5.1 and Kong 0.14.0
-
As shown here (at step 4) and here (at line 22), Kong exposes 4 ports;
-
Tsuru supports only one port per container.
So, in this scenario we have a conflict. Kong needs 4 ports to work properly and Tsuru only accepts one port.
To prove that, if you execute tsuru app-deploy -i kong -a kong-helloworld
you will get this error:
Deploying image... ok
---- Getting process from image ----
---- Inspecting image "kong:latest" ----
---- ERROR during deploy: ----
Too many ports. You should especify which one you want to.
We've create a Dockerfile based on Kong oficial image that exposes only one port.
So, to get it done, clone this project, open your terminal and execute this command:
chmod +x docker-entrypoint.sh
Then, execute this command to build your image:
docker build -t YOUR_CUSTOM_KONG_IMAGE_NAME .
Now you are able to push this image to Docker Hub or a registry of your choice. To push the image created to Docker Hub execute this command:
docker push YOUR_CUSTOM_KONG_IMAGE_NAME
Then you can deploy kong in Tsuru running this command:
tsuru app-deploy -i YOUR_CUSTOM_KONG_IMAGE_NAME -a kong-helloworld
Last but not least, you can register and create a route to Kong admin API in Tsuru, running these commands:
- Access the kong's shell.
tsuru app-shell -a kong-helloworld
- Registry Kong admin API
curl -X POST http://localhost:8001/services \
--data name=admin-api \
--data host=localhost \
--data port=8001
- Creates a route to access Kong admin API.
curl -X POST http://localhost:8001/services/admin-api/routes \
--data paths[]=/admin-api
Note:
To see the deploy automated take a look at the gitlab-ci.yaml in this project.
By the way... thanks to @jhonyscamacho, @matheuscruzsouza, @wallacegsouza, @ronanrf and @patrezze.