Project

General

Profile

Ucloud » History » Version 13

Nico Schottelius, 07/21/2019 09:38 AM

1 13 Nico Schottelius
h1. ucloud (pre v1)
2 1 Ahmed Bilal
3 7 Nico Schottelius
{{toc}}
4
5 11 Nico Schottelius
h2. Preface
6 1 Ahmed Bilal
7
The main development work is described in ticked #6869.
8 13 Nico Schottelius
This manual is in an *early development status*.
9 1 Ahmed Bilal
10 11 Nico Schottelius
Notations:
11
12
* $DOMAIN: refers to a dns domain that you will use for running ucloud
13
14
h2. Administrator Manual
15
16
(being written: how to setup the ucloud infrastructure)
17
18
h3. Requirements
19
20
ucloud is an opinionated cloud management framework. It is made to solve the problem of "virtual machine hosting" including migrations, scale out, etc. While there are many different ways on how to run, store and distribute VMs, there are not that many ways that work reliable and scale out. For this reason ucloud is based on existing software that has proven to be working for virtual machine hosting.
21
22
The following components are required for running ucloud:
23
24
1. Python 3.7, pip, pipenv (the programming language of choice)
25
2. etcd (for data storage)
26
3. ceph (for storage of VMs)
27
4. Guacamole (for console access)
28
29
Setting up these components is out of scope of this manual.
30
31
h3. Base installation
32
33 6 Ahmed Bilal
**Note:** This installation guide assumes that the ~ is /root
34
35
* **Install QEMU**
36
<pre><code class="shell">
37
sudo apt install qemu qemu-kvm
38
</code></pre>
39
40
41
* **Create Directory Structure**
42
<pre><code class="shell">
43
mkdir /var/vm/
44
mkdir /var/www/
45
</code></pre>
46
47
48
* **Create User Directories**
49
<pre><code class="shell">
50
mkdir /var/www/ahmedbilal-admin
51
mkdir /var/www/nico
52
mkdir /var/www/kjg
53
cd ~
54
</code></pre>
55
56
* **Download and place Alpine Linux image in _/var/www/ahmedbilal-admin_**
57
<pre><code class="shell">
58
wget https://www.dropbox.com/s/5eyryhxun6847hx/alpine.zip?dl=1 -O alpine.zip
59
unzip alpine.zip
60
mv alpine.qcow2 /var/www/ahmedbilal-admin
61
</code></pre>
62
63
* **Clone repos**
64
<pre><code class="shell">
65
git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-api.git
66
git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-scheduler.git
67
git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-vm.git
68
git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-file-scan.git
69
git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-image-scanner.git
70
</code></pre>
71 1 Ahmed Bilal
72 6 Ahmed Bilal
73 11 Nico Schottelius
h3. Env file installation
74 6 Ahmed Bilal
75
* **Run "ucloud-api" as daemon**
76
<pre><code class="shell">
77
cd ucloud-api
78
pipenv install
79
pipenv run gunicorn --bind [::]:80 main:app --daemon
80
wget https://www.dropbox.com/s/lyu3atymxyw3846/setup.py?dl=1 -O setup.py
81
pipenv run python setup.py
82
cd ~
83
</code></pre>
84
85
* **Run "ucloud-scheduler" as daemon**
86
<pre><code class="shell">
87
cd ucloud-scheduler
88
pipenv install
89
pipenv run python main.py &>/dev/null &
90
cd ~
91
</code></pre>
92
93
* **Run "ucloud-vm" as daemon**
94
<pre><code class="shell">
95
cd ucloud-vm
96
pipenv install
97
pipenv run python main.py /v1/host/1 --vm True &>/dev/null &
98
cd ~
99
</code></pre>
100
101
* **Install ucloud-file-scan**
102
<pre><code class="shell">
103
cd ucloud-file-scan
104
pipenv install
105
cd ~
106
</code></pre>
107
108
* **Install ucloud-image-scanner**
109
<pre><code class="shell">
110
cd ucloud-image-scanner
111
pipenv install
112
cd ~
113
</code></pre>
114
115
* **Run @crontab -e@ and put these entries there and save by pressing @Ctrl+x@ then @y@ then @enter@**
116
<pre>
117
*/1 * * * * (cd /root/ucloud-file-scan && /usr/local/bin/pipenv run python main.py)
118
*/1 * * * * (cd /root/ucloud-image-scanner/ && /usr/local/bin/pipenv run python main.py)
119 1 Ahmed Bilal
</pre>
120
121
122 11 Nico Schottelius
h2. User Manual
123
124
(being written: how to use ucloud as a user)
125
126
h3. Creating a VM
127
128
(to be filled in by ahmed)
129
130
h3. Viewing the console of the VM
131
132
* Go to console.$DOMAIN
133
* Login with your username password
134
* Select the VM that you want to view
135
136
h3. Deleting a VM
137
138
139
h2. API reference
140
141
(to be moved here by Ahmed)
142
143
144
h3. ucloud-api
145
146 1 Ahmed Bilal
Outside world (indirect) communication with the internal systems.
147
148
Its responsibilities are
149
* Create VM *(Done)* POST _/vm/create_ 
150
<pre><code class="javascript">
151
{
152
	"name": "username",
153
	"realm": "user_realm",
154
	"seed": "user_seed",
155
	"specs": {
156
		"cpu": 16,
157 2 Ahmed Bilal
		"ram": 256,
158
		"hdd": 2000,
159 1 Ahmed Bilal
		"ssd": 256
160
	}
161
}
162
</code></pre>
163
164
* Delete VM *(Done)* POST _/vm/delete_
165
<pre><code class="javascript">
166
{
167
	"name": "username",
168
	"realm": "user_realm",
169
	"seed": "user_seed",
170
	"vmid": "id_of_virtual_machine"
171
}
172
</code></pre>
173
174
* Status VM *(Done)* GET _/vm/status_
175
<pre><code class="javascript">
176
{
177
	"id": "id_of_virtual_machine"
178
}
179
</code></pre>
180
181
* Create new network
182
* Attach network to VM
183
* Detach network from VM
184
* Delete network
185
186 11 Nico Schottelius
h3. ucloud-scheduler
187 1 Ahmed Bilal
188
It schedules/reschedules VM that are created using ucloud-api. How does it schedules? It does by watching any changes under the _/v1/vm/_ prefix. Basically, it deals with two ETCD entries
189
190
1. Virtual Machines Entries that looks like
191
<pre><code class="javascript">
192
/v1/vm/1
193
{
194
  "owner": "ahmedbilal-admin",
195
  "specs": {
196
    "cpu": 20,
197
    "ram": 2,
198 8 Nico Schottelius
    "hdd": 10,
199 9 Nico Schottelius
    "ssd": 10
200
  },
201 10 Nico Schottelius
  "hostname": "",
202
  "status": "REQUESTED_NEW" 
203 9 Nico Schottelius
}
204
</code></pre>
205
2. Hosts Entries that look like
206
<pre><code class="javascript">
207 8 Nico Schottelius
/v1/host/1
208
{
209
    "cpu": 32,
210
    "ram": 128,
211
    "hdd": 1024,
212
    "ssd": 0
213
    "status": "UP"
214 1 Ahmed Bilal
}
215
</code></pre>
216
217 9 Nico Schottelius
It loop through list of host entries found under _/v1/host/_ and check whether we can run the incoming VM on that host. if we can, then it (ucloud-scheduler) sets the hostname key of incoming VM to that host. Suppose, our scheduler decides that we can run the earlier shown VM _/v1/vm/1_ on _/v1/host/1_. Then, our updated entry would look like
218
219
<pre><code class="javascript">
220
/v1/vm/1
221 8 Nico Schottelius
{
222
  "owner": "ahmedbilal-admin",
223
  "specs": {
224
    "cpu": 20,
225
    "ram": 2,
226
    "hdd": 10,
227
    "ssd": 10
228
  },
229 1 Ahmed Bilal
  "hostname": "/v1/host/1",
230
  "status": "REQUESTED_NEW" 
231
}
232 9 Nico Schottelius
</code></pre>
233
234
*Note* the hostname key/value pair.
235
236 12 Nico Schottelius
h3. ucloud-vm
237
238 8 Nico Schottelius
It is responsible for creating (running) / deleting (stopping) / monitoring virtual machines
239
240
It watches the _/v1/vm/_ prefix for any changes like (Virtual Machines with status like *SCHEDULED_DEPLOY* or *REQUEST_DELETE*.
241
242
On, *SCHEDULED_DEPLOY* it creates the VM and run it. On, *REQUEST_DELETE* it stops the VM. 
243
244
It is also responsible for monitoring VM statues i.e whether they are RUNNING or KILLED (in action). If a VM is killed we put that in log file, notify system administrator and restart it.