This library provides
- service containerization with docker
- service discovery and automatic registration/deregistartion with etcd and registrator
- service node assignment with consistent hashing
-
Install docker on your machines
-
Launch an etcd cluster
Do it your way or the easiest way via etcd_docker
- Install registrator on all machines in the cluster
docker run -d --name=registrator --net=host --volume=/var/run/docker.sock:/tmp/docker.sock
gliderlabs/registrator etcd://<your etcd endpoint ip:port>/services
Note: all services will be registered under etcd's /services keyspace.
Start a few busybox containers with different ports
docker run -d -p 8081:8081 busybox
docker run -d -p 8082:8082 busybox
Go to example dir and
go run main.go --endpoints=http://<your etcd endpoint ip:port> --service_name=/services/busybox
Then stop/restart a few containers and check how a service node is assigned accordingly.