Ucloud » History » Revision 5
Revision 4 (Ahmed Bilal, 07/02/2019 09:17 AM) → Revision 5/16 (Ahmed Bilal, 07/02/2019 09:17 AM)
h1. ucloud (To Be Continued) h2. Requirements 1. Python 3.7, pip, pipenv 2. etcd 3. ceph h2. ucloud-api Outside world (indirect) communication with the internal systems. Its responsibilities are * Create VM *(Done)* POST _/vm/create_ <pre><code class="javascript"> { "name": "username", "realm": "user_realm", "seed": "user_seed", "specs": { "cpu": 16, "ram": 256, "hdd": 2000, "ssd": 256 } } </code></pre> * Delete VM *(Done)* POST _/vm/delete_ <pre><code class="javascript"> { "name": "username", "realm": "user_realm", "seed": "user_seed", "vmid": "id_of_virtual_machine" } </code></pre> * Status VM *(Done)* GET _/vm/status_ <pre><code class="javascript"> { "id": "id_of_virtual_machine" } </code></pre> * Create new network * Attach network to VM * Detach network from VM * Delete network h2. ucloud-scheduler 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 1. Virtual Machines Entries that looks like <pre><code class="javascript"> /v1/vm/1 { "owner": "ahmedbilal-admin", "specs": { "cpu": 20, "ram": 2, "hdd": 10, "ssd": 10 }, "hostname": "", "status": "REQUESTED_NEW" } </code></pre> 2. Hosts Entries that look like <pre><code class="javascript"> /v1/host/1 { "cpu": 32, "ram": 128, "hdd": 1024, "ssd": 0 "status": "UP" } </code></pre> 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 <pre><code class="javascript"> /v1/vm/1 { "owner": "ahmedbilal-admin", "specs": { "cpu": 20, "ram": 2, "hdd": 10, "ssd": 10 }, "hostname": "/v1/host/1", "status": "REQUESTED_NEW" } </code></pre> *Note* the hostname key/value pair. h2. ucloud-vm It is responsible for creating (running) / deleting (stopping) / monitoring virtual machines It watches the _/v1/vm/_ prefix for any changes like (Virtual Machines with status like *SCHEDULED_DEPLOY* or *REQUEST_DELETE*. On, *SCHEDULED_DEPLOY* it creates the VM and run it. On, *REQUEST_DELETE* it stops the VM. 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.