Project

General

Profile

Ucloud » History » Version 11

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

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