Skip to content
This repository has been archived by the owner on Sep 6, 2024. It is now read-only.

Commit

Permalink
Merge pull request #7 from gfieni/master
Browse files Browse the repository at this point in the history
Several improvements for v2 release
  • Loading branch information
rouvoy authored Apr 3, 2017
2 parents ea3b0b2 + 15a0fa2 commit 9d1f097
Show file tree
Hide file tree
Showing 17 changed files with 1,260 additions and 475 deletions.
15 changes: 10 additions & 5 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,24 +3,29 @@ language: go
go_import_path: github.com/Spirals-Team/docker-g5k

env:
# Linux
- GIMME_OS=linux GIMME_ARCH=amd64
- GIMME_OS=linux GIMME_ARCH=386
# MacOS
- GIMME_OS=darwin GIMME_ARCH=amd64
- GIMME_OS=darwin GIMME_ARCH=386
# Windows
- GIMME_OS=windows GIMME_ARCH=amd64
- GIMME_OS=windows GIMME_ARCH=386

install:
- go get -d -v ./...
- go get -d -t -v ./...

script:
- go test ./...
# Only run tests on Linux
- if [ $BUILD_GOOS == "linux" ] ; then go test -v ./... ; fi
- go build -v -o docker-g5k-$GIMME_OS-$GIMME_ARCH

deploy:
provider: releases
skip_cleanup: true
file: "docker-g5k-$GIMME_OS-$GIMME_ARCH"

on:
tags: true

api_key:
secure: AmCrDfWm2XV6tNawIpcq/eLdHl83ns5foq3+CBE/RjF2ncqhLProvbZf8LeYivtA+Q/fbWV6LK3I2cQKFWj3h47llwL0goeq2GW3VpQBx9vEnDrZbR0T3XydWAD7BgHVKXDs6ppk3c1F+QtVWuKxyc/4whN+uRDwckMmZ+ZJQacCf6mutMA1xxQYZFbZ/QCI+hrbRaQNgPuN7LAOoWq9SMpnE5EcMNj2vdEWsS6wcFRmO6ZDweTXt2aLQqrilBVfQfdG58U2PmAQNvYGjN/uJeliIOph4wwhkDR5qMQguex/dPvytps+tEShKYpPJD0lGNhTk/fM0J6Gyw1VxTTbN+jDw3MvUccFMl+yUM2puTRwBTdSBb5wcABjeQIk+C5TS9Hx8woiV+OasK9a/0Ar5DogpDWFrM99VyXoYA9ilUG22JzNlAoIHHpWAIuIrG0637tlV66We4fWWUMbj1Smh0ZJ1AqzuB8f23PkYBf0pDETO77Y1Mrb6WrchKmyK/IhIf0JlBAEBBBEfCAnaa8PeGTSlEIJoBeEZf4dg6daOUtC1azXIL7GNw0wpJ7ah7ziWNZhH1L1F1ZhZCWUHCqwsZkRUtSfaG9C/wZuHZiz7mcfDnUQ8leBXbWJIVQ9+fyEMPeqlq7vNbSSikrV+icTbLw8k1zCwfy9BJGJShPsT8Q=
secure: AmCrDfWm2XV6tNawIpcq/eLdHl83ns5foq3+CBE/RjF2ncqhLProvbZf8LeYivtA+Q/fbWV6LK3I2cQKFWj3h47llwL0goeq2GW3VpQBx9vEnDrZbR0T3XydWAD7BgHVKXDs6ppk3c1F+QtVWuKxyc/4whN+uRDwckMmZ+ZJQacCf6mutMA1xxQYZFbZ/QCI+hrbRaQNgPuN7LAOoWq9SMpnE5EcMNj2vdEWsS6wcFRmO6ZDweTXt2aLQqrilBVfQfdG58U2PmAQNvYGjN/uJeliIOph4wwhkDR5qMQguex/dPvytps+tEShKYpPJD0lGNhTk/fM0J6Gyw1VxTTbN+jDw3MvUccFMl+yUM2puTRwBTdSBb5wcABjeQIk+C5TS9Hx8woiV+OasK9a/0Ar5DogpDWFrM99VyXoYA9ilUG22JzNlAoIHHpWAIuIrG0637tlV66We4fWWUMbj1Smh0ZJ1AqzuB8f23PkYBf0pDETO77Y1Mrb6WrchKmyK/IhIf0JlBAEBBBEfCAnaa8PeGTSlEIJoBeEZf4dg6daOUtC1azXIL7GNw0wpJ7ah7ziWNZhH1L1F1ZhZCWUHCqwsZkRUtSfaG9C/wZuHZiz7mcfDnUQ8leBXbWJIVQ9+fyEMPeqlq7vNbSSikrV+icTbLw8k1zCwfy9BJGJShPsT8Q=
191 changes: 138 additions & 53 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,22 +1,33 @@
[![Build Status](https://travis-ci.org/Spirals-Team/docker-g5k.svg)](https://travis-ci.org/Spirals-Team/docker-g5k)

# docker-g5k
A tool to create a Docker Swarm cluster for Docker Machine on Grid5000 testbed infrastructure.
It only support creating and deleting nodes in Docker Machine.
A tool to create a Docker Swarm cluster for Docker Machine on the Grid5000 testbed infrastructure.

## Requirements
* [Docker](https://www.docker.com/products/overview#/install_the_platform)
* [Docker Machine](https://docs.docker.com/machine/install-machine)
* [Docker Machine Driver for Grid5000](https://github.com/Spirals-Team/docker-machine-driver-g5k)
* [Go tools](https://golang.org/doc/install)
* [Docker Machine Driver for Grid5000 (v1.4.1+)](https://github.com/Spirals-Team/docker-machine-driver-g5k)
* [Go tools (Only for installation from sources)](https://golang.org/doc/install)

You need a Grid5000 account to use this tool. See [this page](https://www.grid5000.fr/mediawiki/index.php/Grid5000:Get_an_account) to create an account.

## Installation

## Installation from GitHub releases
Binary releases for Linux, MacOS and Windows using x86/x86_64 CPU architectures are available in the [releases page](https://github.com/Spirals-Team/docker-g5k/releases).
You can use the following commands to install or upgrade the tool:
```bash
# download the binary for your OS and CPU architecture :
sudo curl -L -o /usr/local/bin/docker-g5k "<link to release>"

# grant execution rigths for everyone :
sudo chmod 755 /usr/local/bin/docker-g5k
```

## Installation from sources
*This procedure was only tested on Ubuntu 16.04.*

To use the Go tools, you need to set your [GOPATH](https://golang.org/doc/code.html#GOPATH) variable environment.

To use the Go tools, you need to set your [GOPATH](https://golang.org/doc/code.html#GOPATH) variable environment.
To get the code and compile the binary, run:
```bash
go get -u github.com/Spirals-Team/docker-g5k
Expand All @@ -35,66 +46,140 @@ Do not forget to configure your DNS or use OpenVPN DNS auto-configuration.
Please follow the instructions from the [Grid5000 Wiki](https://www.grid5000.fr/mediawiki/index.php/VPN).

### Command line flags

#### Cluster creation flags

| Option | Description | Default value | Required |
|------------------------------|---------------------------------------------------------|-----------------------|------------|
| `--g5k-username` | Your Grid5000 account username | | Yes |
| `--g5k-password` | Your Grid5000 account password | | Yes |
| `--g5k-site` | Site to reserve the resources on | | Yes |
| `--g5k-nb-nodes` | Number of nodes to allocate | 3 | No |
| `--g5k-walltime` | Timelife of the machine | "1:00:00" | No |
| `--g5k-ssh-private-key` | Path of your ssh private key | "~/.ssh/id_rsa" | No |
| `--g5k-ssh-public-key` | Path of your ssh public key | "< private-key >.pub" | No |
| `--g5k-image` | Name of the image to deploy | "jessie-x64-min" | No |
| `--g5k-resource-properties` | Resource selection with OAR properties (SQL format) | | No |
| `--swarm-discovery` | Discovery service to use with Swarm | Generate a new token | No |
| `--swarm-image` | Specify Docker image to use for Swarm | "swarm:latest" | No |
| `--swarm-strategy` | Define a default scheduling strategy for Swarm | "spread" | No |
| `--swarm-opt` | Define arbitrary flags for Swarm master | | No |
| `--swarm-join-opt` | Define arbitrary flags for Swarm join | | No |
| `--swarm-master-join` | Make Swarm master join the Swarm pool | False | No |
| `--weave-networking` | Use Weave for networking | False | No |

#### Cluster deletion flags

| Option | Description | Default value | Required |
|------------------------------|---------------------------------------------------------|-----------------------|------------|
| `--g5k-job-id` | Only remove nodes related to the provided job ID | | No |
Flags marked with `[ ]` can be given multiple times and the values will be added.

Flags marked with `{ }` support brace expansion (same format as sh/bash shells) to generate combinations.
Please refer to the flags format in "Flags usage" section of the command.

#### For `create-cluster` command

##### Flags description
* **`--g5k-username` : Your Grid5000 account username (required)**
* **`--g5k-password` : Your Grid5000 account password (required)**
* **`--g5k-reserve-nodes` : Reserve nodes on a site (required)**
* `--g5k-walltime` : Timelife of the nodes (format: "hh:mm:ss")
* `--g5k-image` : Name of the image to deploy on the nodes
* `--g5k-resource-properties` : Resource selection with OAR properties (SQL format)
* `--engine-opt` : Specify flags to include on the selected node(s) engine
* `--engine-label` : Specify labels for the selected node(s) engine
* `--swarm-master` : Select node(s) to be promoted to Swarm Master
* `--swarm-mode-enable` : Create a Swarm mode cluster
* `--swarm-standalone-enable` : Create a Swarm standalone cluster
* `--swarm-standalone-discovery` : Discovery service to use with Swarm
* `--swarm-standalone-image` : Specify the Docker image to use for Swarm
* `--swarm-standalone-strategy` : Define a default scheduling strategy for Swarm
* `--swarm-standalone-opt` : Define arbitrary global flags for Swarm master
* `--swarm-standalone-join-opt` : Define arbitrary global flags for Swarm join
* `--weave-networking` : Use Weave for networking (Only with Swarm standalone)

##### Flags usage
| Option | Environment | Default value | { } | [ ] |
|--------------------------------|------------------------------|-----------------------|-----|-----|
| `--g5k-username` | `G5K_USERNAME` | | No | No |
| `--g5k-password` | `G5K_PASSWORD` | | No | No |
| `--g5k-reserve-nodes` | `G5K_RESERVE_NODES` | | Yes | Yes |
| `--g5k-walltime` | `G5K_WALLTIME` | "1:00:00" | No | No |
| `--g5k-image` | `G5K_IMAGE` | "jessie-x64-min" | No | No |
| `--g5k-resource-properties` | `G5K_RESOURCE_PROPERTIES` | | No | No |
| `--engine-opt` | `ENGINE_OPT` | | Yes | Yes |
| `--engine-label` | `ENGINE_LABEL` | | Yes | Yes |
| `--swarm-master` | `SWARM_MASTER` | | Yes | Yes |
| `--swarm-mode-enable` | `SWARM_MODE_ENABME` | | No | No |
| `--swarm-standalone-enable` | `SWARM_STANDALONE_ENABLE` | | No | No |
| `--swarm-standalone-discovery` | `SWARM_STANDALONE_DISCOVERY` | New token | No | No |
| `--swarm-standalone-image` | `SWARM_STANDALONE_IMAGE` | "swarm:latest" | No | No |
| `--swarm-standalone-strategy` | `SWARM_STANDALONE_STRATEGY` | "spread" | No | No |
| `--swarm-standalone-opt` | `SWARM_STANDALONE_OPT` | | No | Yes |
| `--swarm-standalone-join-opt` | `SWARM_STANDALONE_JOIN_OPT` | | No | Yes |
| `--weave-networking` | `WEAVE_NETWORKING` | | No | No |

Flag `--g5k-reserve-nodes` format is `site:numberOfNodes` and brace expansion are supported.
For example, `lille-16`, `{lille,nantes}-16`.

Engine flags `--engine-*` format is `node-name:key=val` and brace expansion are supported.
For example, `lille-0:mykey=myval`, `lille-{0..5}:mykey=myval`, `lille-{0,2,4}:mykey=myval`.

For `--engine-opt` flag, please refer to [Docker documentation](https://docs.docker.com/engine/reference/commandline/dockerd/) for supported parameters.
**Test your parameters on a single node before deploying a cluster ! If your flags are incorrect, Docker wont start and you should redeploy the entire cluster !**

#### For `remove-cluster` command

##### Flags description
* `--g5k-job-id` : Only remove nodes related to the provided job ID

##### Flags usage
| Option | Environment | Default value | { } | [ ] |
|--------------------------------|------------------------------|-----------------------|-----|-----|
| `--g5k-job-id` | `G5K_JOB_ID` | | No | Yes |

### Examples

#### Cluster creation

An example of a 3 nodes Docker Swarm cluster creation:
An example of a 16 nodes Docker reservation (Only Docker, Swarm is not configured):
```bash
docker-g5k create-cluster \
--g5k-username "user" \
--g5k-password "********" \
--g5k-reserve-nodes "lille:16" \
```

An example of a 16 nodes Docker reservation with Engine options and labels:
```bash
docker-g5k create-cluster \
--g5k-username "user" \
--g5k-password "********" \
--g5k-reserve-nodes "lille:16" \
--engine-opt "lille-{0..15}:graph=/tmp" \
--engine-label "lille-0:mylabelname1=mylabelvalue1" \
--engine-label "lille-{1..5}:mylabelname2=mylabelvalue2"
```

An example of a 16 nodes Docker reservation using resource properties (nodes with more thant 8GB of RAM and at least 4 CPU cores):
```bash
docker-g5k create-cluster \
--g5k-username "user" \
--g5k-password "********" \
--g5k-reserve-nodes "lille:16" \
--g5k-resource-properties "memnode > 8192 and cpucore >= 4"
```

An example of multi-sites cluster creation:
```bash
docker-g5k create-cluster \
--g5k-username "user" \
--g5k-password "********" \
--g5k-reserve-nodes "lille:16" \
--g5k-reserve-nodes "nantes:8"
```

An example of multi-sites cluster creation using brace expansion:
```bash
docker-g5k create-cluster \
--g5k-username user \
--g5k-password ******** \
--g5k-site lille \
--g5k-ssh-private-key ~/.ssh/g5k-key
--g5k-username "user" \
--g5k-password "********" \
--g5k-reserve-nodes "{lille,nantes}:16"
```

An example where 3 nodes join an existing Docker Swarm cluster using a discovery token:
An example of a 16 nodes Docker Swarm mode cluster creation using the first 3 nodes as Swarm Master:
```bash
docker-g5k create-cluster \
--g5k-username user \
--g5k-password ******** \
--g5k-site lille \
--swarm-discovery "token://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
--g5k-ssh-private-key ~/.ssh/g5k-key
--g5k-username "user" \
--g5k-password "********" \
--g5k-reserve-nodes "lille:16" \
--swarm-mode-enable \
--swarm-master "lille-{0..2}"
```

An example of a 16 nodes Docker Swarm cluster creation with resource properties (nodes in cluster `chimint` with more thant 8GB of RAM and at least 4 CPU cores):
An example of a 16 nodes Docker Swarm standalone cluster creation using the first node as Swarm Master and Weave Networking:
```bash
docker-g5k create-cluster \
--g5k-username user \
--g5k-password ******** \
--g5k-site lille \
--g5k-ssh-private-key ~/.ssh/g5k-key \
--g5k-nb-nodes 16 \
--g5k-resource-properties "cluster = 'chimint' and memnode > 8192 and cpucore >= 4"
--g5k-username "user" \
--g5k-password "********" \
--g5k-reserve-nodes "lille:16" \
--swarm-standalone-enable \
--swarm-master "lille-0" \
--weave-networking
```

#### Cluster deletion
Expand All @@ -119,7 +204,7 @@ docker-machine ls

**If you remove a node with Docker Machine 'rm' command, the job will be deleted and ALL nodes related to this job will become unavailable**

### Use with Weave networking
### Use with Weave networking (Only with Swarm standalone)

First, you need to configure your Docker client to use the Swarm mode (You can get the Swarm master hostname with 'docker-machine ls'):
```bash
Expand All @@ -128,7 +213,7 @@ eval $(docker-machine env --swarm swarm-master-node-name)

Then run a container using Weave networking:
```bash
docker run --net=weave -h foo.weave.local --name foo $(~/.docker/machine/weave-net dns-args) -td your-image:version
docker run --net=weave -h foo.weave.local --name foo --dns=172.17.0.1 --dns-search=weave.local. -td your-image:version
```
Your containers can now communicate with each other using theirs short ('foo') or long ('foo.weave.local') name.
The name used NEED to be the one given in parameter '-h'. The name of the container (parameter '--name') is not used by Weave.
50 changes: 0 additions & 50 deletions command/commands.go

This file was deleted.

Loading

0 comments on commit 9d1f097

Please sign in to comment.