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