README.md 4.1 KB
Newer Older
Armand Grillet's avatar
Armand Grillet committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
#Configuration to run Allgo

##Woody (your computer)
Needs: Ruby 2.2.2-dev, Nginx, mariadb, ruby + rails via rvm, rails app (via capistrano), redis, docker, git, zip, curl,sudo

Use RVM to install the correct version of Ruby and make it the default one.
```zsh
rvm --default use ruby-2.2.2-dev
```

The Gemfile will install the gem mysql2 that needs MariaDB and Sidekiq that needs Redis:
```zsh
sudo yum install mariadb-devel
sudo yum install redis
sudo service redis start
```

To run the project you need to migrate the project's database:
```zsh
rake db:migrate
```

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

## Infrastructure
There is three types of machines in the infrastructure (other than Woody):
- The workers, not connected to Internet. There are just here to do the jobs asked. 
- Sid, a worker with an internet connection.
- Cargo, the Docker registry used by workers to do ```docker pull``` commands.
The best way to create the infrastructure is to build your first worker then you can clone your machines to create more workers, Sid and Cargo.

###Installation of Debian and Docker
We're using VM VirtualBox to simulate the workers. Download a .iso of Debian, launch your VM and configure it (we're creating a new user called 'allgo' in this example). Once it boots, you need to configure it to be ready for Docker:

```zsh
sudo
su -c "adduser allgo sudo"
sudo apt-get install curl
curl -sSL https://get.docker.com/ | sh
sudo usermod -aG docker allgo
sudo systemctl enable docker
```

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
```

###Allowing insecuring registries
As we do not have an HTTPS certification yet, you need to allow insecure registries:

####Debian < v8
```zsh
sudo nano /etc/default/docker
```
Then modify the line concerning DOCKER_OPTS to have: ```DOCKER_OPTS="--insecure-registry cargo.irisa.fr:5000"```.

####Debian >= v8
```zsh
sudo nano /lib/systemd/system/docker.service
```

Change one line to have ```ExecStart=/usr/bin/docker --insecure-registry myregistry:5000 -d -H fd://```

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

###A different IP address for every machine
All the workers should have a different IP address configured. Add in VirtualBox second host-only adapter in the Network tab. This adapter sould be in promiscuous mode allowing VMs witha connected cable.

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
```
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
sudo apt-get install openssh-server 
```

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
```

##Cargo
You need to install docker-registry on it:
```zsh
docker pull registry
```

When running the registry, you need to mount a datastore:
```zsh
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
```