https://github.com/ncarlier/kong-docker-daemon
This is a sidekick docker daemon used to automatically declare upstreams and targets into Kong.
https://github.com/ncarlier/kong-docker-daemon
Last synced: 7 months ago
JSON representation
This is a sidekick docker daemon used to automatically declare upstreams and targets into Kong.
- Host: GitHub
- URL: https://github.com/ncarlier/kong-docker-daemon
- Owner: ncarlier
- License: mit
- Created: 2017-07-19T16:03:25.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2017-11-05T22:32:01.000Z (almost 8 years ago)
- Last Synced: 2024-10-29T07:04:17.970Z (11 months ago)
- Language: Go
- Size: 17.6 KB
- Stars: 5
- Watchers: 6
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Kong Docker Daemon
This is a sidekick [Docker][docker] daemon used to automatically declare
upstreams and targets into [Kong][kong].## Usage
Start the sidekick container:
```bash
$ docker run -d \
--volume /var/run/docker.sock:/var/run/docker.sock \
ncarlier/kong-docker-daemon
```Now if you start a container exposing a port and having the label
`kong.upstream`, this container IP and PORT will be declared in Kong as a target
for the labeled upstream.Example:
```bash
$ docker run -d \
--label "kong.upstream:sample.foo" \
infrastructureascode/hello-world
```## Demo
You can try the demonstration by using the following command:
```bash
$ make deploy logs
```This command will deploy the following Docker stack:
- A [PostgreSQL](postgresql) instance
- A Kong instance using PostgreSQL as database backend
- A [Konga](konga) instance allowing you to explore and configure Kong with a
pretty GUI (http://localhost:1337)
- A HelloWorld sample API backend with `sample.foo` as upstream name
- And this sidekick daemonThe sidekick daemon should create the upstream `sample.foo` into Kong and add
the container IP and port as an active target of this upstream.
If you play with the status of this sample service you should see impacts onto
the Kong configuration.Example:
```bash
$ curl -XGET http://localhost:8001/upstreams/sample.foo/targets/active | jq .
$ docker-compose scale sample=2
$ curl -XGET http://localhost:8001/upstreams/sample.foo/targets/active | jq .
$ docker-compose scale sample=1
$ curl -XGET http://localhost:8001/upstreams/sample.foo/targets/active | jq .
$ docker-compose scale sample=0
$ curl -XGET http://localhost:8001/upstreams/sample.foo/targets/active | jq .
$ ...
```---
[docker]: https://www.docker.com/
[kong]: https://getkong.org
[konga]: https://github.com/pantsel/konga
[postgresql]: https://www.postgresql.org/