Project

General

Profile

Ucloud » History » Version 3

Ahmed Bilal, 07/01/2019 02:03 PM

1 1 Ahmed Bilal
h1. ucloud (To Be Continued)
2
3
h2. ucloud-api
4
5
Outside world (indirect) communication with the internal systems.
6
7
Its responsibilities are
8
* Create VM *(Done)* POST _/vm/create_ 
9
<pre><code class="javascript">
10
{
11
	"name": "username",
12
	"realm": "user_realm",
13
	"seed": "user_seed",
14
	"specs": {
15
		"cpu": 16,
16
		"ram": 256,
17 2 Ahmed Bilal
		"hdd": 2000,
18
		"ssd": 256
19 1 Ahmed Bilal
	}
20
}
21
</code></pre>
22
23
* Delete VM *(Done)* POST _/vm/delete_
24
<pre><code class="javascript">
25
{
26
	"name": "username",
27
	"realm": "user_realm",
28
	"seed": "user_seed",
29
	"vmid": "id_of_virtual_machine"
30
}
31
</code></pre>
32
33
* Status VM *(Done)* GET _/vm/status_
34
<pre><code class="javascript">
35
{
36
	"id": "id_of_virtual_machine"
37
}
38
</code></pre>
39
40
* Create new network
41
* Attach network to VM
42
* Detach network from VM
43
* Delete network
44
45
h2. ucloud-scheduler
46
47
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
48
49
1. Virtual Machines Entries that looks like
50
<pre><code class="javascript">
51
/v1/vm/1
52
{
53
  "owner": "ahmedbilal-admin",
54
  "specs": {
55
    "cpu": 20,
56
    "ram": 2,
57
    "hdd": 10,
58 3 Ahmed Bilal
    "ssd": 10
59 1 Ahmed Bilal
  },
60
  "hostname": "",
61
  "status": "REQUESTED_NEW" 
62
}
63
</code></pre>
64
2. Hosts Entries that look like
65
<pre><code class="javascript">
66
/v1/host/1
67
{
68
    "cpu": 32,
69
    "ram": 128,
70
    "hdd": 1024,
71 3 Ahmed Bilal
    "ssd": 0
72 1 Ahmed Bilal
    "status": "UP"
73
}
74
</code></pre>
75
76
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
77
78
<pre><code class="javascript">
79
/v1/vm/1
80
{
81
  "owner": "ahmedbilal-admin",
82
  "specs": {
83
    "cpu": 20,
84
    "ram": 2,
85
    "hdd": 10,
86 3 Ahmed Bilal
    "ssd": 10
87 1 Ahmed Bilal
  },
88
  "hostname": "/v1/host/1",
89
  "status": "REQUESTED_NEW" 
90
}
91
</code></pre>
92
93
*Note* the hostname key/value pair.
94
95
h2. ucloud-vm
96
It is responsible for creating (running) / deleting (stopping) / monitoring virtual machines
97
98
It watches the _/v1/vm/_ prefix for any changes like (Virtual Machines with status like *SCHEDULED_DEPLOY* or *REQUEST_DELETE*.
99
100
On, *SCHEDULED_DEPLOY* it creates the VM and run it. On, *REQUEST_DELETE* it stops the VM. 
101
102
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.