Code Monkey home page Code Monkey logo

docker-serf's Introduction

Serf on Docker

This is a docker image and a couple of helper bash function, to work with serf.

This document describe the process:

  • create the docker image
  • start a cluster of connected serf agent running in docker containers
  • stop/start nodes to check how membership gossip works

Create the image

git clone [email protected]:sequenceiq/docker-serf.git
cd docker-serf
git checkout serf-only
docker build -t sequenceiq/serf .

start a demo cluster

run 3 docker container from the image you just built. all of them is running in the background (-d docker parameter)

  • serf0 the first one doesn't joins to a cluster as he is the first
  • serf<1..n> nodes connecting to the cluster

serf-start-cluster function defaults to starting 3 nodes. if you want more just add a parameter serf-start-cluster 5

# load helper bash functions serf-xxx
. serf-functions

# start a cluster with 3 nodes
serf-start-cluster

# check the running nodes
docker ps

start a test node and attach

it starts a new container name serf99, but not in the brackound, like the previous ones. you will be attached to the container, which:

  • joins the cluster
  • starts a /bin/bash ready to use
serf-test-instance

# once attached to the test instance prompt changes to [bash-4.1#]
serf members

you will see now all memebers including the test instance itself serf99

serf99.mycorp.kom  172.17.0.5:7946  alive  
serf1.mycorp.kom   172.17.0.3:7946  alive  
serf0.mycorp.kom   172.17.0.2:7946  alive  
serf2.mycorp.kom   172.17.0.4:7946  alive

Start/stop a node

Stop one of the nodes:

docker stop -t 0 serf1

now if you run again the serf members in serf99 you will notice serf1 node marked as failed. note: it might take a couple of seconds, until the cluster gossips around the failure of node99.

serf99.mycorp.kom  172.17.0.5:7946  alive
serf1.mycorp.kom   172.17.0.3:7946  failed  
serf0.mycorp.kom   172.17.0.2:7946  alive
serf2.mycorp.kom   172.17.0.4:7946  alive

if you resart the node serf1:

docker start serf1

It will apear again as live. Check it on serf99:

serf members

serf99.mycorp.kom  172.17.0.5:7946  alive  
serf1.mycorp.kom   172.17.0.3:7946  alive  
serf0.mycorp.kom   172.17.0.2:7946  alive  
serf2.mycorp.kom   172.17.0.4:7946  alive

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.