init cluster using ucp
docker image pull docker/ucp:2.2.3
# see https://docs.docker.com/datacenter/ucp/2.2/reference/cli/install/#options
docker container run --rm -it --name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp:2.2.3 install \
--admin-username=admin \
--admin-password=12345678 \
--swarm-port 3376 \
--host-address $(ipconfig getifaddr en0) # $(ipconfig getifaddr en0) == xxx.xxx.xxx.xxx, where en0 - is your network interface
# or interactive
docker container run --rm -it --name ucp \
-v /var/run/docker.sock:/var/run/docker.sock \
docker/ucp:2.2.3 install \
--host-address 192.168.0.123 \
--interactive
create overlay network
docker network create -d overlay kong-application
create and run global stateful database service
docker service create --detach=false \
--name kong-database \
-p 5432:5432 \
-e "POSTGRES_USER=kong" \
-e "POSTGRES_DB=kong" \
--mode global \
--health-cmd="pg_isready -U postgres"\
--health-interval=10s \
--health-timeout=5s \
--health-retries=5 \
--network kong-application \
--mount type=volume,source=postgres-data,destination=/var/lib/postgresql/data,volume-label="type=service",volume-label="name=kong-database" \
postgres:9.4-alpine
run kong migration
docker pull kong:0.11.0
docker service create --detach=true \
--name migrations \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_CASSANDRA_CONTACT_POINTS=kong-database" \
--network kong-application \
kong:0.11.0 kong migrations -v up
docker service logs migrations
docker service rm migrations
run stateless services: kong and dashboard
docker service create --detach=false \
--name kong \
-p 8000:8000 \
-p 8001:8001 \
-p 8443:8443 \
-p 8444:8444 \
-e "KONG_DATABASE=postgres" \
-e "KONG_PG_HOST=kong-database" \
-e "KONG_PG_DATABASE=kong" \
--replicas 1 \
--health-cmd="curl -I -s -L http://127.0.0.1:8000 || exit 1"\
--health-interval=10s \
--health-timeout=5s \
--health-retries=5 \
--network kong-application \
--mount type=volume,source=kong-data,destination=/usr/local/kong,volume-label="type=service",volume-label="name=kong" \
kong:0.11.0
docker service create --detach=false \
--name dashboard \
-p 8080:8080 \
--replicas 1 \
--network kong-application \
pgbi/kong-dashboard:v2
check deployment open http://0.0.0.0:8080/
check cluster info open https://0.0.0.0/
bash kong-docker-swarm-using-ucp/swarm-start.bash bash kong-docker-swarm-using-ucp/swarm-scale.bash bash kong-docker-swarm-using-ucp/swarm-cleanup.bash