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

Commit 9d1f097

Browse files
authored
Merge pull request #7 from gfieni/master
Several improvements for v2 release
2 parents ea3b0b2 + 15a0fa2 commit 9d1f097

17 files changed

+1260
-475
lines changed

.travis.yml

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,24 +3,29 @@ language: go
33
go_import_path: github.com/Spirals-Team/docker-g5k
44

55
env:
6+
# Linux
67
- GIMME_OS=linux GIMME_ARCH=amd64
8+
- GIMME_OS=linux GIMME_ARCH=386
9+
# MacOS
710
- GIMME_OS=darwin GIMME_ARCH=amd64
11+
- GIMME_OS=darwin GIMME_ARCH=386
12+
# Windows
813
- GIMME_OS=windows GIMME_ARCH=amd64
14+
- GIMME_OS=windows GIMME_ARCH=386
915

1016
install:
11-
- go get -d -v ./...
17+
- go get -d -t -v ./...
1218

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

1724
deploy:
1825
provider: releases
1926
skip_cleanup: true
2027
file: "docker-g5k-$GIMME_OS-$GIMME_ARCH"
21-
2228
on:
2329
tags: true
24-
2530
api_key:
26-
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=
31+
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=

README.md

Lines changed: 138 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -1,22 +1,33 @@
1+
[![Build Status](https://travis-ci.org/Spirals-Team/docker-g5k.svg)](https://travis-ci.org/Spirals-Team/docker-g5k)
2+
13
# docker-g5k
2-
A tool to create a Docker Swarm cluster for Docker Machine on Grid5000 testbed infrastructure.
3-
It only support creating and deleting nodes in Docker Machine.
4+
A tool to create a Docker Swarm cluster for Docker Machine on the Grid5000 testbed infrastructure.
45

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

1112
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.
1213

1314
## Installation
1415

16+
## Installation from GitHub releases
17+
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).
18+
You can use the following commands to install or upgrade the tool:
19+
```bash
20+
# download the binary for your OS and CPU architecture :
21+
sudo curl -L -o /usr/local/bin/docker-g5k "<link to release>"
22+
23+
# grant execution rigths for everyone :
24+
sudo chmod 755 /usr/local/bin/docker-g5k
25+
```
26+
1527
## Installation from sources
1628
*This procedure was only tested on Ubuntu 16.04.*
1729

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

3748
### Command line flags
38-
39-
#### Cluster creation flags
40-
41-
| Option | Description | Default value | Required |
42-
|------------------------------|---------------------------------------------------------|-----------------------|------------|
43-
| `--g5k-username` | Your Grid5000 account username | | Yes |
44-
| `--g5k-password` | Your Grid5000 account password | | Yes |
45-
| `--g5k-site` | Site to reserve the resources on | | Yes |
46-
| `--g5k-nb-nodes` | Number of nodes to allocate | 3 | No |
47-
| `--g5k-walltime` | Timelife of the machine | "1:00:00" | No |
48-
| `--g5k-ssh-private-key` | Path of your ssh private key | "~/.ssh/id_rsa" | No |
49-
| `--g5k-ssh-public-key` | Path of your ssh public key | "< private-key >.pub" | No |
50-
| `--g5k-image` | Name of the image to deploy | "jessie-x64-min" | No |
51-
| `--g5k-resource-properties` | Resource selection with OAR properties (SQL format) | | No |
52-
| `--swarm-discovery` | Discovery service to use with Swarm | Generate a new token | No |
53-
| `--swarm-image` | Specify Docker image to use for Swarm | "swarm:latest" | No |
54-
| `--swarm-strategy` | Define a default scheduling strategy for Swarm | "spread" | No |
55-
| `--swarm-opt` | Define arbitrary flags for Swarm master | | No |
56-
| `--swarm-join-opt` | Define arbitrary flags for Swarm join | | No |
57-
| `--swarm-master-join` | Make Swarm master join the Swarm pool | False | No |
58-
| `--weave-networking` | Use Weave for networking | False | No |
59-
60-
#### Cluster deletion flags
61-
62-
| Option | Description | Default value | Required |
63-
|------------------------------|---------------------------------------------------------|-----------------------|------------|
64-
| `--g5k-job-id` | Only remove nodes related to the provided job ID | | No |
49+
Flags marked with `[ ]` can be given multiple times and the values will be added.
50+
51+
Flags marked with `{ }` support brace expansion (same format as sh/bash shells) to generate combinations.
52+
Please refer to the flags format in "Flags usage" section of the command.
53+
54+
#### For `create-cluster` command
55+
56+
##### Flags description
57+
* **`--g5k-username` : Your Grid5000 account username (required)**
58+
* **`--g5k-password` : Your Grid5000 account password (required)**
59+
* **`--g5k-reserve-nodes` : Reserve nodes on a site (required)**
60+
* `--g5k-walltime` : Timelife of the nodes (format: "hh:mm:ss")
61+
* `--g5k-image` : Name of the image to deploy on the nodes
62+
* `--g5k-resource-properties` : Resource selection with OAR properties (SQL format)
63+
* `--engine-opt` : Specify flags to include on the selected node(s) engine
64+
* `--engine-label` : Specify labels for the selected node(s) engine
65+
* `--swarm-master` : Select node(s) to be promoted to Swarm Master
66+
* `--swarm-mode-enable` : Create a Swarm mode cluster
67+
* `--swarm-standalone-enable` : Create a Swarm standalone cluster
68+
* `--swarm-standalone-discovery` : Discovery service to use with Swarm
69+
* `--swarm-standalone-image` : Specify the Docker image to use for Swarm
70+
* `--swarm-standalone-strategy` : Define a default scheduling strategy for Swarm
71+
* `--swarm-standalone-opt` : Define arbitrary global flags for Swarm master
72+
* `--swarm-standalone-join-opt` : Define arbitrary global flags for Swarm join
73+
* `--weave-networking` : Use Weave for networking (Only with Swarm standalone)
74+
75+
##### Flags usage
76+
| Option | Environment | Default value | { } | [ ] |
77+
|--------------------------------|------------------------------|-----------------------|-----|-----|
78+
| `--g5k-username` | `G5K_USERNAME` | | No | No |
79+
| `--g5k-password` | `G5K_PASSWORD` | | No | No |
80+
| `--g5k-reserve-nodes` | `G5K_RESERVE_NODES` | | Yes | Yes |
81+
| `--g5k-walltime` | `G5K_WALLTIME` | "1:00:00" | No | No |
82+
| `--g5k-image` | `G5K_IMAGE` | "jessie-x64-min" | No | No |
83+
| `--g5k-resource-properties` | `G5K_RESOURCE_PROPERTIES` | | No | No |
84+
| `--engine-opt` | `ENGINE_OPT` | | Yes | Yes |
85+
| `--engine-label` | `ENGINE_LABEL` | | Yes | Yes |
86+
| `--swarm-master` | `SWARM_MASTER` | | Yes | Yes |
87+
| `--swarm-mode-enable` | `SWARM_MODE_ENABME` | | No | No |
88+
| `--swarm-standalone-enable` | `SWARM_STANDALONE_ENABLE` | | No | No |
89+
| `--swarm-standalone-discovery` | `SWARM_STANDALONE_DISCOVERY` | New token | No | No |
90+
| `--swarm-standalone-image` | `SWARM_STANDALONE_IMAGE` | "swarm:latest" | No | No |
91+
| `--swarm-standalone-strategy` | `SWARM_STANDALONE_STRATEGY` | "spread" | No | No |
92+
| `--swarm-standalone-opt` | `SWARM_STANDALONE_OPT` | | No | Yes |
93+
| `--swarm-standalone-join-opt` | `SWARM_STANDALONE_JOIN_OPT` | | No | Yes |
94+
| `--weave-networking` | `WEAVE_NETWORKING` | | No | No |
95+
96+
Flag `--g5k-reserve-nodes` format is `site:numberOfNodes` and brace expansion are supported.
97+
For example, `lille-16`, `{lille,nantes}-16`.
98+
99+
Engine flags `--engine-*` format is `node-name:key=val` and brace expansion are supported.
100+
For example, `lille-0:mykey=myval`, `lille-{0..5}:mykey=myval`, `lille-{0,2,4}:mykey=myval`.
101+
102+
For `--engine-opt` flag, please refer to [Docker documentation](https://docs.docker.com/engine/reference/commandline/dockerd/) for supported parameters.
103+
**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 !**
104+
105+
#### For `remove-cluster` command
106+
107+
##### Flags description
108+
* `--g5k-job-id` : Only remove nodes related to the provided job ID
109+
110+
##### Flags usage
111+
| Option | Environment | Default value | { } | [ ] |
112+
|--------------------------------|------------------------------|-----------------------|-----|-----|
113+
| `--g5k-job-id` | `G5K_JOB_ID` | | No | Yes |
65114

66115
### Examples
67116

68117
#### Cluster creation
69118

70-
An example of a 3 nodes Docker Swarm cluster creation:
119+
An example of a 16 nodes Docker reservation (Only Docker, Swarm is not configured):
120+
```bash
121+
docker-g5k create-cluster \
122+
--g5k-username "user" \
123+
--g5k-password "********" \
124+
--g5k-reserve-nodes "lille:16" \
125+
```
126+
127+
An example of a 16 nodes Docker reservation with Engine options and labels:
128+
```bash
129+
docker-g5k create-cluster \
130+
--g5k-username "user" \
131+
--g5k-password "********" \
132+
--g5k-reserve-nodes "lille:16" \
133+
--engine-opt "lille-{0..15}:graph=/tmp" \
134+
--engine-label "lille-0:mylabelname1=mylabelvalue1" \
135+
--engine-label "lille-{1..5}:mylabelname2=mylabelvalue2"
136+
```
137+
138+
An example of a 16 nodes Docker reservation using resource properties (nodes with more thant 8GB of RAM and at least 4 CPU cores):
139+
```bash
140+
docker-g5k create-cluster \
141+
--g5k-username "user" \
142+
--g5k-password "********" \
143+
--g5k-reserve-nodes "lille:16" \
144+
--g5k-resource-properties "memnode > 8192 and cpucore >= 4"
145+
```
146+
147+
An example of multi-sites cluster creation:
148+
```bash
149+
docker-g5k create-cluster \
150+
--g5k-username "user" \
151+
--g5k-password "********" \
152+
--g5k-reserve-nodes "lille:16" \
153+
--g5k-reserve-nodes "nantes:8"
154+
```
155+
156+
An example of multi-sites cluster creation using brace expansion:
71157
```bash
72158
docker-g5k create-cluster \
73-
--g5k-username user \
74-
--g5k-password ******** \
75-
--g5k-site lille \
76-
--g5k-ssh-private-key ~/.ssh/g5k-key
159+
--g5k-username "user" \
160+
--g5k-password "********" \
161+
--g5k-reserve-nodes "{lille,nantes}:16"
77162
```
78163

79-
An example where 3 nodes join an existing Docker Swarm cluster using a discovery token:
164+
An example of a 16 nodes Docker Swarm mode cluster creation using the first 3 nodes as Swarm Master:
80165
```bash
81166
docker-g5k create-cluster \
82-
--g5k-username user \
83-
--g5k-password ******** \
84-
--g5k-site lille \
85-
--swarm-discovery "token://xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx" \
86-
--g5k-ssh-private-key ~/.ssh/g5k-key
167+
--g5k-username "user" \
168+
--g5k-password "********" \
169+
--g5k-reserve-nodes "lille:16" \
170+
--swarm-mode-enable \
171+
--swarm-master "lille-{0..2}"
87172
```
88173

89-
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):
174+
An example of a 16 nodes Docker Swarm standalone cluster creation using the first node as Swarm Master and Weave Networking:
90175
```bash
91176
docker-g5k create-cluster \
92-
--g5k-username user \
93-
--g5k-password ******** \
94-
--g5k-site lille \
95-
--g5k-ssh-private-key ~/.ssh/g5k-key \
96-
--g5k-nb-nodes 16 \
97-
--g5k-resource-properties "cluster = 'chimint' and memnode > 8192 and cpucore >= 4"
177+
--g5k-username "user" \
178+
--g5k-password "********" \
179+
--g5k-reserve-nodes "lille:16" \
180+
--swarm-standalone-enable \
181+
--swarm-master "lille-0" \
182+
--weave-networking
98183
```
99184

100185
#### Cluster deletion
@@ -119,7 +204,7 @@ docker-machine ls
119204

120205
**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**
121206

122-
### Use with Weave networking
207+
### Use with Weave networking (Only with Swarm standalone)
123208

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

129214
Then run a container using Weave networking:
130215
```bash
131-
docker run --net=weave -h foo.weave.local --name foo $(~/.docker/machine/weave-net dns-args) -td your-image:version
216+
docker run --net=weave -h foo.weave.local --name foo --dns=172.17.0.1 --dns-search=weave.local. -td your-image:version
132217
```
133218
Your containers can now communicate with each other using theirs short ('foo') or long ('foo.weave.local') name.
134219
The name used NEED to be the one given in parameter '-h'. The name of the container (parameter '--name') is not used by Weave.

command/commands.go

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
 (0)