Sign inSign up

vicampo/kong

By vicampo

Updated over 7 years ago

Api router based on kong

Image
0

816

vicampo/kong repository overview

Kong Development Setup (Platform) and Container Build

This repository provides Kong - an HTTP API router based on Nginx/ OpenResty®.

Vicampo uses Kong to manage access to the different services. The APIs are configured in Kong and Kong restricts access to these for each request.

The API router Kong is deployed as an ECS Service. Its ECS service and task definition live in routers/wms/. The service connects to a target group of the load balancer, which is required if you want to load balance traffic to an ECS service, seeeu-west-1 ecs_service.json file

.. note::

It was intended to have more than one router configuration in the routers/
folder. But as of now, there is only the need for one (wms).

This repository contains everything needed for the development setup of Kong to work with the Vagrant box.

Installing Kong for the Vagrant Box Platform

In this section: For development, the Docker compose utility can be used to run the Vicampo Kong setup to a great extend in an automated manner.

Configure Vagrant Platform local.php

To start the installation of Kong for the Vagrant Platform, the application configuration must be aligned with the system and credential configuration in this repository.

This is done by adding the URL incl. IP and port as well as the Kong API key and authorization

<?php


return [
    'resources' => [
        'variables' => [
            # ...
            'kong_api_url_dev' => 'http://192.168.33.1:8001',
            'kong_api_key' => '9a41392542074ee4991d01fe798d888d',
            'auth_access_token' => 'eeg2Doo2yighahlegohs7eewee0uoqu0oTh',
            # ...
            # 'static_cdn_domain' => 'vicampo.test',
        ],
    ],
];

Don't forget to clean the cache (e. g. vagrant ssh -c vic-cache-clean).

Development Installation Script

To install Kong execute the install target:

$ make install
Verify the Installation

Fire an exemplary request against Kong (400 Bad Request expected):

$ curl -i -k -X POST -H 'host: api.vicampo.test' https://localhost:8443/v1/auth/login

The Kong dashboard is available at port 8080.

In case of any issues, double check the configuration and re-run the installation from scratch:

$ make reinstall
Update the Kongfig Configuration

While running the development setup, one might want to test a changed/updated kongfig.yml file. This can be easily done via:

$ docker-compose run kongfig kongfig --path /config.yml --host kong:8001

Kong Usage

In the kong/ folder lives the Dockerfile that defines the image that will be run as ECS service. If you want to change the way Kong works change this image. E.g., if you want to change configuration of either Nginx or Kong itself see custom_nginx.template or kong.production.conf respectively.

After you have made your changes you need to build and publish the image using

$ make kong-release

The resulting image is pushed to ER (which is why you might need to login to ECR first using the command

$ aws ecr login

After you have build the image you can deploy the new version using the scripts/update-router.sh) script. It requires a single parameter which is the name of the folder in routers/ you want to update.

$ scripts/update-router.sh wms

That will deploy the task definition and inactivate all others of the same family. It will also restart the service.

Resources

Tag summary

Content type

Image

Digest

Size

69 MB

Last updated

over 7 years ago

docker pull vicampo/kong