GithubHelp home page GithubHelp logo

drcon's Introduction

Service discovery with DRCoN

An example built for the Medellin DevOps meetup, based on this article.

Dependencies

Run the example

You can run each container in a separate terminal window. If you're on Linux, remember to run eval $(docker-machine env <machine name>) before, so that window can communicate with the docker daemon running in your VM.

Run the Consul container:

$ docker run -it -h node \
-p 8500:8500 -p 8600:53/udp \
progrium/consul \
-server -bootstrap \
-advertise $(docker-machine ip <machine name>) \
-log-level debug

Run the Registrator container:

$ docker run -it \
-v /var/run/docker.sock:/tmp/docker.sock \
-h $(docker-machine ip <machine name>) \
gliderlabs/registrator \
consul://$(docker-machine ip <machine name>):8500

Run DR-CoN

If you haven't, pull the DR-CoN container Dockerfile.

$ git clone https://github.com/grahamjenson/DR-CoN.git

Build it:

$ cd DR-CoN
$ docker build -t dr-con .

Run it:

$ docker run -it \
-e "CONSUL=$(docker-machine ip <machine name>):8500" \
-e "SERVICE=server" \
-p 80:80 dr-con

Run the Go server:

$ docker build -t server
$ docker run --publish 6060:8080 server

Go to http://localhost:6060/Johnny, and say hello!

Note: If you're not on Linux, make sure you installed Docker Machine. Then run

$ docker-machine ip <machine name>

to get your virtual machine's IP. Replace "localhost" with that IP in the above URL, and you should be ready to go! Run more instances changing the mapped port (first one in 6060:8080), in the Run the Go server step. Notice that if you reload the page multiple times, the displayed IP changes. That's Consul Template doing its magic!

You can also check how Registrator detects when a new service is run and registers it on the Consul server. Go to http://localhost:8500 and you should see it on Consul's UI. Replace "localhost" for your VM's IP if you're not on linux.

drcon's People

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.