At Fri, 24 Jul 2015 00:20:34 -0400, Christopher Durkin wrote: > > From: Chris Durkin <[email protected]> > > Adds Dockerfile and scripts for creating clusters of containers. > For details see docker/README.md. > > Signed-off-by: Chris Durkin <[email protected]> > --- > Dockerfile | 20 +++++++++++++ > docker/README.md | 76 > +++++++++++++++++++++++++++++++++++++++++++++++++ > docker/build.sh | 7 +++++ > docker/cdog | 6 ++++ > docker/corosync.conf | 74 +++++++++++++++++++++++++++++++++++++++++++++++ > docker/run.sh | 9 ++++++ > docker/start_cluster.sh | 18 ++++++++++++ > 7 files changed, 210 insertions(+) > create mode 100644 Dockerfile > create mode 100644 docker/README.md > create mode 100755 docker/build.sh > create mode 100755 docker/cdog > create mode 100644 docker/corosync.conf > create mode 100644 docker/run.sh > create mode 100755 docker/start_cluster.sh
Applied, thanks. Hitoshi > > diff --git a/Dockerfile b/Dockerfile > new file mode 100644 > index 0000000..14e8816 > --- /dev/null > +++ b/Dockerfile > @@ -0,0 +1,20 @@ > +FROM ubuntu:14.04 > +RUN apt-get -qq update > +RUN apt-get -qq install -y gcc autoconf yasm pkg-config libtool make > +RUN apt-get -qq install -y corosync libcorosync-dev crmsh > +RUN apt-get -qq install -y liburcu-dev libqb-dev > +ENV SHEEPSRC /usr/src/sheepdog > +ENV SHEEPPORT 7000 > +ENV SHEEPSTORE /store > +ADD ./docker/corosync.conf /etc/corosync/corosync.conf > +ADD ./docker/run.sh /root/run.sh > + > +WORKDIR $SHEEPSRC > +ADD . $SHEEPSRC > +RUN ./autogen.sh > +RUN ./configure && make && make check && make install > + > +RUN mkdir $SHEEPSTORE > + > +EXPOSE $SHEEPPORT > +CMD /bin/bash /root/run.sh > diff --git a/docker/README.md b/docker/README.md > new file mode 100644 > index 0000000..40df3b2 > --- /dev/null > +++ b/docker/README.md > @@ -0,0 +1,76 @@ > +Installing docker > +================= > + > +For complete info, visit the [Docker > +site](https://docs.docker.com/installation/). For quick start, see > +sections below. > + > +On Ubuntu > +--------- > + > +Install the docker daemon using apt. Note the package name. > + > + apt-get install docker.io > + > + > +On Mac > +------ > + > +Using homebrew, boot2docker, and virtualbox is easiest. > + > + brew install boot2docker > + boot2docker init > + boot2docker up > + > + > +Building container image > +============== > + > +Use `docker build .` from the source root directory, or use > +`docker/build.sh` to automatically tag the image. Alternatively, > +download an image from docker.io and specify the image name in the > +next step. > + > +After building or pulling the image, it should be visible when running > +`docker images`. > + > + > +Running a cluster > +================= > + > +All scripts are controlled using environment variables (all caps). > + > + IMAGE - docker image name, for building or starting containers > + NODE - for running commands on containers, the name of the node > + DOCKER - the docker command (try DOCKER="sudo docker" on linux) > + > +Use `docker/start_cluster.sh` to start a 3 node corosync cluster with > +sheep running on each one. You can specify the node names with NODES, > +or default to "n1 n2 n3". If any of the nodes already exist they will > +be killed and removed. You can specify the image with IMAGE, or > +default to sheepdog:latest. > + > +Use `docker/cdog` to run dog commands on the cluster nodes. You can > +specify the target node with NODE=nodename, or default to n1. > + > +A full example: > + > + ./docker/build.sh > + ./docker/start_cluster.sh > + ./docker/cdog cluster format > + ./docker/cdog cluster info > + > +Running an image from docker.io: > + > + export IMAGE=cjdnxx/sheepdog > + docker pull $IMAGE > + ./docker/start_cluster.sh # uses IMAGE env var > + > +After starting the cluster, use `docker ps` to see the running > +containers. > + > +Pause containers with `docker pause`, then unpause with `docker > +unpause` to simulate machines temporarily leaving the cluster. Use > +`docker kill` to nuke a container. Note that IP addresses are assigned > +dynamically so a killed container will appear as a new node, even if > +it has the same host name. > diff --git a/docker/build.sh b/docker/build.sh > new file mode 100755 > index 0000000..18c77f8 > --- /dev/null > +++ b/docker/build.sh > @@ -0,0 +1,7 @@ > +#!/bin/bash -x > + > +srcdir=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) > +image=${IMAGE:-sheepdog:latest} > +docker=${DOCKER:-docker} > + > +$docker build -t $image $srcdir/.. > diff --git a/docker/cdog b/docker/cdog > new file mode 100755 > index 0000000..62d2679 > --- /dev/null > +++ b/docker/cdog > @@ -0,0 +1,6 @@ > +#!/bin/bash > + > +node=${NODE:-n1} > +docker=${DOCKER:-docker} > + > +$docker exec -t $node /usr/sbin/dog $* > diff --git a/docker/corosync.conf b/docker/corosync.conf > new file mode 100644 > index 0000000..b87488a > --- /dev/null > +++ b/docker/corosync.conf > @@ -0,0 +1,74 @@ > +# Please read the openais.conf.5 manual page > + > +totem { > + version: 2 > + > + # How long before declaring a token lost (ms) > + token: 3000 > + > + # How many token retransmits before forming a new configuration > + token_retransmits_before_loss_const: 10 > + > + # How long to wait for join messages in the membership protocol (ms) > + join: 60 > + > + # How long to wait for consensus to be achieved before starting a new > round of membership configuration (ms) > + consensus: 3600 > + > + # Turn off the virtual synchrony filter > + vsftype: none > + > + # Number of messages that may be sent by one processor on receipt of > the token > + max_messages: 20 > + > + # Limit generated nodeids to 31-bits (positive signed integers) > + clear_node_high_bit: yes > + > + # Disable encryption > + secauth: off > + > + # How many threads to use for encryption/decryption > + threads: 0 > + > + # Optionally assign a fixed node id (integer) > + # nodeid: 1234 > + > + # This specifies the mode of redundant ring, which may be none, active, > or passive. > + rrp_mode: none > + > + interface { > + # The following values need to be set based on your environment > + ringnumber: 0 > + #bindnetaddr: 127.0.0.1 > + bindnetaddr: 172.17.0.0 > + #mcastaddr: 226.94.1.1 > + mcastaddr: 224.0.55.55 > + mcastport: 5405 > + } > +} > + > +amf { > + mode: disabled > +} > + > +quorum { > + # Quorum for the Pacemaker Cluster Resource Manager > + provider: corosync_votequorum > + expected_votes: 1 > +} > + > +aisexec { > + user: root > + group: root > +} > + > +logging { > + fileline: off > + to_stderr: no > + to_logfile: yes > + to_syslog: no > + logfile: /var/log/corosync/corosync.log > + syslog_facility: daemon > + debug: on > + timestamp: on > +} > diff --git a/docker/run.sh b/docker/run.sh > new file mode 100644 > index 0000000..fac9a37 > --- /dev/null > +++ b/docker/run.sh > @@ -0,0 +1,9 @@ > +#!/bin/bash > +# cmd run on container creation (only call within a container) > +# leave a bash shell as the foreground process > + > +env > +/usr/sbin/corosync > +service pacemaker start > +/usr/sbin/sheep -c corosync $SHEEPSTORE -p $SHEEPPORT > +/bin/bash > diff --git a/docker/start_cluster.sh b/docker/start_cluster.sh > new file mode 100755 > index 0000000..6664845 > --- /dev/null > +++ b/docker/start_cluster.sh > @@ -0,0 +1,18 @@ > +#!/bin/bash -x > + > +image=${IMAGE:-sheepdog:latest} > +nodes=${NODES:-"n1 n2 n3"} > +docker=${DOCKER:-docker} > + > +echo "Killing old cluster..." > +for node in $nodes; do > + $docker kill $node > + $docker rm $node > +done > + > +sleep 1 > + > +echo "Starting new cluster..." > +for node in $nodes; do > + $docker run -h $node -d --name=$node -t $image > +done > -- > 2.3.2 (Apple Git-55) > > -- > sheepdog mailing list > [email protected] > https://lists.wpkg.org/mailman/listinfo/sheepdog -- sheepdog mailing list [email protected] https://lists.wpkg.org/mailman/listinfo/sheepdog
