this is demo of traffic management with open resty, Consul, and registrator
docker-machine create -d virtualbox default docker-machine create -d virtualbox host1 docker-machine create -d virtualbox host2 docker-machine create -d virtualbox host3
docker-machine start default docker-machine start host1 docker-machine start host2 docker-machine start host3
NAME ACTIVE DRIVER STATE URL SWARM DOCKER ERRORS default - virtualbox Running tcp://192.168.99.100:2376 v1.12.1 host1 - virtualbox Running tcp://192.168.99.101:2376 v1.12.1 host2 - virtualbox Running tcp://192.168.99.102:2376 v1.12.1 host3 - virtualbox Running tcp://192.168.99.103:2376 v1.12.1
(regenerate certs if necessary docker-machine regenerate-certs default host1 host2 host3 )
cd base-resty; ./build-base-image.sh; cd -
cd api-gateway; ./build-gateway-image.sh; cd -
eval $(docker-machine env host3)
docker run --rm -p 8400:8400 -p 8500:8500 consul agent -datacenter=kgi -server -client=0.0.0.0 -bootstrap -ui
http://gliderlabs.com/registrator/latest/
./deploy-registrator.sh 1 ./deploy-registrator.sh 2
at this time we can see that consul console show only consul service at http://192.168.99.103:8500
./deploy-echo-service.sh host1 ./deploy-echo-service.sh host2
http://192.168.99.103:8500/ui/#/vbtdev/services now show one or two instances available
Consul UI http://192.168.99.103:8500
Consul API http://192.168.99.103:8500/v1/catalog/services
Echo-service call http://192.168.99.100:8000/api/echo-service/headers
we can manage registration info by simply specifying different environment
variables
docker run --rm -P
-e "SERVICE_NAME=echo-service-test"
-e "SERVICE_TAGS=http,v1-candidate"
echo-service
docker-machine stop host3 host2 host1 default
https://blog.uship.com/shippingcode/connectivity-between-nginx-and-consul-template/
http://blog.cloud66.com/9-crtitical-decisions-needed-to-run-docker-in-production/
https://github.com/hashicorp/consul-template
https://github.com/hashicorp/envconsul
https://studio.zerobrane.com/ Debugging Lua on nginx server http://notebook.kulchenko.com/zerobrane/debugging-openresty-nginx-lua-scripts-with-zerobrane-studio
Register a service manually
curl -X PUT 192.168.99.104:8500/v1/catalog/register
--data @register-service.json