README.md 6.63 KB
Newer Older
1
                    _
MAUPETIT Charly's avatar
MAUPETIT Charly committed
2
3
4
5
6
7
8
9
           _       | |    _____  ____
     /\   | |      | |   / ____|/ __ \
    /  \  | |      | |  | |  __| |  | |
   / /\ \ | |      | |  | | |_ | |  | |
  / ____ \| |____  | |  | |__| | |__| |
 /_/    \_\______| | |   \_____|\____/
                   |_|

10

MAUPETIT Charly's avatar
MAUPETIT Charly committed
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#What is Allgo (A||Go)
A||Go est une infrastructure web pour mettre en ligne le plus rapidement et simplement
possible des logiciels ou prototypes scientifiques. L'objectif est de réduire le coût du transfert de
l'ordinateur du chercheur vers les utilisateurs finaux (membre de l’équipe, communauté
scientifique,Startup PME, grand public).
Le déploiement des applications, et surtout leurs utilisations, s'en retrouvent simplifiés. On peut les exécuter via l'interface web ou une API HTTP.
Techniquement, A||Go est basé sur le framework Ruby on Rails pour offrir une interface web
et des services HTTP REST, ainsi que l’utilisation de Docker pour la gestion des images applicatives.
Docker fournit des conteneurs Linux pour gérer / stocker / utiliser les applications que nous
hébergeons.
Un job est l'action d'exécuter une application, avc un ou plusieurs fichier(s) qui retournera un résultat.

#Architecture
![](doc/allgo.jpg)

## Woody (web server) - Debian 8
MAUPETIT Charly's avatar
MAUPETIT Charly committed
27
### What
MAUPETIT Charly's avatar
MAUPETIT Charly committed
28
Allgo frontend via the web application in RoR. We also have the datastore on Woody, to store files from jobs, and the SQL database.
MAUPETIT Charly's avatar
MAUPETIT Charly committed
29
### Need
30
Ruby 2.2.2-dev, Nginx, mariadb, ruby + rails via rvm, rails app (via capistrano), redis, git, zip, curl, sudo
MAUPETIT Charly's avatar
MAUPETIT Charly committed
31
### How
MAUPETIT Charly's avatar
MAUPETIT Charly committed
32
33
34
35
36
37
38
39
su -c "adduser allgo"
su -c "usermod -aG sudo allgo"
su allgo

Use RVM to install the correct version of Ruby
```zsh
\curl -sSL https://get.rvm.io | bash
rvm install ruby-2.2.2-dev
Armand Grillet's avatar
Armand Grillet committed
40
41
rvm --default use ruby-2.2.2-dev
```
MAUPETIT Charly's avatar
MAUPETIT Charly committed
42
43
44
45
Install the gem bundler to download the dependancies
```zsh
gem install bundler
```
Armand Grillet's avatar
Armand Grillet committed
46
47

```zsh
MAUPETIT Charly's avatar
MAUPETIT Charly committed
48
49
sudo apt-get install mariadb-devel redis -y
sudo service redis enable (to launch at boot)
Armand Grillet's avatar
Armand Grillet committed
50
sudo service redis start
MAUPETIT Charly's avatar
MAUPETIT Charly committed
51
52
sudo service mariadb enable
sudo service mariadb start
Armand Grillet's avatar
Armand Grillet committed
53
54
```

MAUPETIT Charly's avatar
MAUPETIT Charly committed
55
To run the project you need to migrate the project's database, there are backup in db/backup
Armand Grillet's avatar
Armand Grillet committed
56
```zsh
MAUPETIT Charly's avatar
MAUPETIT Charly committed
57
58
rake db:create ( RAILS_ENV=production )
rake db:migrate ( RAILS_ENV=production )
Armand Grillet's avatar
Armand Grillet committed
59
60
61
62
63
64
65
```

Then launch the project and check if there is no error message in the correct port:
```zsh
rails s
```

MAUPETIT Charly's avatar
MAUPETIT Charly committed
66
67
We also need to run sidekiq separately :
```zsh
MAUPETIT Charly's avatar
MAUPETIT Charly committed
68
bundle exec sidekiq (-e production)
MAUPETIT Charly's avatar
MAUPETIT Charly committed
69
```
Armand Grillet's avatar
Armand Grillet committed
70

MAUPETIT Charly's avatar
MAUPETIT Charly committed
71
##WorkerX
MAUPETIT Charly's avatar
MAUPETIT Charly committed
72
### What
MAUPETIT Charly's avatar
MAUPETIT Charly committed
73
74
The worker are server that will execute job created by users in Allgo.
we sent the command through ssh from Woody and send a docker pull request to cargo (see below)
MAUPETIT Charly's avatar
MAUPETIT Charly committed
75
76
the datastore from woody is mount through ssh so Worker can write in.
### Need
MAUPETIT Charly's avatar
MAUPETIT Charly committed
77
78
Docker 1.6, openssh-server
### How
Armand Grillet's avatar
Armand Grillet committed
79
80

```zsh
MAUPETIT Charly's avatar
MAUPETIT Charly committed
81
82
83
84
85
86
87
88
su -c "apt-get update && apt-get install sudo openssh-server -y"
su -c "adduser allgo"
su -c "usermod -aG sudo allgo"
su allgo
```
Install the last docker version docker :
```zsh
curl + curl -sSL https://test.docker.com/ | sh
Armand Grillet's avatar
Armand Grillet committed
89
sudo usermod -aG docker allgo
MAUPETIT Charly's avatar
MAUPETIT Charly committed
90
/etc/init.d/docker start
Armand Grillet's avatar
Armand Grillet committed
91
92
93
94
95
96
97
98
99
100
101
102
103
```

Try a Docker command to see if it works:
```zsh
docker ps
```

If it is not the case:
```zsh
sudo chown allgo /home/allgo/.docker/
sudo chown allgo /home/allgo/.docker/key.json
```

MAUPETIT Charly's avatar
MAUPETIT Charly committed
104
105
*Allowing insecure registry*
As we do not have an HTTPS certification yet, you need to allow an insecure registry in cargo server (see below) :
Armand Grillet's avatar
Armand Grillet committed
106
107
108
109
110

####Debian < v8
```zsh
sudo nano /etc/default/docker
```
Armand Grillet's avatar
Armand Grillet committed
111
Then modify the line concerning DOCKER_OPTS to have: ```DOCKER_OPTS="--insecure-registry <registry_ip>:5000"```.
Armand Grillet's avatar
Armand Grillet committed
112

MAUPETIT Charly's avatar
MAUPETIT Charly committed
113
114
(or myregistry:5000 if development or other server)
#####Debian >= v8
MAUPETIT Charly's avatar
MAUPETIT Charly committed
115

Armand Grillet's avatar
Armand Grillet committed
116
117
118
119
```zsh
sudo nano /lib/systemd/system/docker.service
```

Armand Grillet's avatar
Armand Grillet committed
120
Change one line to have ```ExecStart=/usr/bin/docker --insecure-registry <registry_ip>:5000 -d -H fd://```
Armand Grillet's avatar
Armand Grillet committed
121
122
123
124
125
126

```zsh
sudo systemctl daemon-reload
sudo /etc/init.d/docker restart
```

MAUPETIT Charly's avatar
MAUPETIT Charly committed
127
##Sid - Sandbox
MAUPETIT Charly's avatar
MAUPETIT Charly committed
128
It's the same as worker, but we use it when an user install an application/algorithm.
MAUPETIT Charly's avatar
MAUPETIT Charly committed
129
130
131
132
133
134
135
136
137
138
139
140
141
142
We create the docker image and push it to the registry

##Cargo

Cargo run the docker image registry, which allow us to store our own docker images.
We use a NAS to replicate the created images, it's safer.
Install docker (same as above)
*To run the registry, with external storage*
```zsh
docker pull registry
docker run -d -p 5000:5000 -e SETTING_FLAVOR=dev -e STORAGE_PATH=/the_folder_of/your_choice_on_container/ -v /the_folder_of/your_choice/on_host:/the_folder_of/your_choice_on_container/ registry:latest
```
It's unsecure for the moment.

MAUPETIT Charly's avatar
MAUPETIT Charly committed
143
#The development environment :
MAUPETIT Charly's avatar
MAUPETIT Charly committed
144
145
You can use the Vagrantfile for Virtualbox (no provisioning yet)

MAUPETIT Charly's avatar
MAUPETIT Charly committed
146
Or follow those instructions :
MAUPETIT Charly's avatar
MAUPETIT Charly committed
147
148
Create 4 or 5 VM (depends of if you want to use your host as web server)
Add in VirtualBox second host-only adapter in the Network tab, with DHCP.
Armand Grillet's avatar
Armand Grillet committed
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163

Relaunch your VM and modify the network interfaces:

```zsh
sudo nano /etc/network/interfaces
```

Add in the opened file:
```zsh
auto eth0
iface eth0 inet dhcp

auto eth1
iface eth1 inet dhcp
```
MAUPETIT Charly's avatar
MAUPETIT Charly committed
164

Armand Grillet's avatar
Armand Grillet committed
165
166
167
168
169
170
171
Once you've done the modifications, use the command ``sudo  /etc/init.d/networking restart`` to restart the network card of your VM.

When duplicating the first worker don't forget to check the option to change the MAC address. Run a ```sudo ifconfig``` on each machine to get the IP address and copy-paste them into ``config/environments/development.rb`` in the corresponding line of rails-allgo.

###Installing ssh
You'll use ssh a lot on the workers thus we need to install it on the workers and aloow Woody to do a ssh without having to enter a password. First, install openssh-server:
```zsh
MAUPETIT Charly's avatar
MAUPETIT Charly committed
172
sudo apt-get install openssh-server
Armand Grillet's avatar
Armand Grillet committed
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
```

Then on Woody, assuming that you already have a ssh key, do this for the workers and Sid:
```zsh
ssh allgo@192.168.56.<machine number> mkdir -p .ssh
cat ~/.ssh/id_rsa.pub | ssh allgo@192.168.56.<machine number> 'cat >> .ssh/authorized_keys'
```

###Change the hostname of your machines
After cloning your machines, they'll all have the name worker 0. To change that:
```zsh
sudo nano /etc/hostname
```
Change the name and then:
```zsh
sudo /etc/init.d/hostname.sh start
```
190

MAUPETIT Charly's avatar
MAUPETIT Charly committed
191

192
193
194
195
196
197
198
199
200
#To mount datastore :
nfs-kernel on main server (woody)
on node : vim /etc/fstab
  add : woody.irisa.fr:/mnt/datastore   /mnt/datastore   nfs    user    0   0
do : mount /mnt/datastore
sudo vim /etc/exports
/mnt/datastore/ worker0.irisa.fr(rw,all_squash,anonuid=1000,anongid=1000,sync)
/mnt/datastore/ worker1.irisa.fr(rw,all_squash,anonuid=1000,anongid=1000,sync)
/mnt/datastore/ sid.irisa.fr(rw,all_squash,anonuid=1000,anongid=1000,sync)
MAUPETIT Charly's avatar
MAUPETIT Charly committed
201

Armand Grillet's avatar
Armand Grillet committed
202
203
204
205
206
207
208
209
##Cargo
You need to install docker-registry on it:
```zsh
docker pull registry
```

When running the registry, you need to mount a datastore:
```zsh
Armand Grillet's avatar
Armand Grillet committed
210
docker run -d -p 5000:5000 -e SETTING_FLAVOR=dev -e STORAGE_PATH=/osef/ -v /home/allgo/docker/:/osef/ registry:latest
Armand Grillet's avatar
Armand Grillet committed
211
```
MAUPETIT Charly's avatar
merging    
MAUPETIT Charly committed
212
>>>>>>> 77e928b784484e397f8595b907233d091595ea37