Project

General

Profile

Actions

Ucloud » History » Revision 7

« Previous | Revision 7/16 (diff) | Next »
Nico Schottelius, 07/21/2019 09:21 AM


ucloud (To Be Continued)

Requirements

1. Python 3.7, pip, pipenv
2. etcd
3. ceph

Installation

Note: This installation guide assumes that the ~ is /root

  • Install QEMU
    sudo apt install qemu qemu-kvm
    
  • Create Directory Structure
    mkdir /var/vm/
    mkdir /var/www/
    
  • Create User Directories
    mkdir /var/www/ahmedbilal-admin
    mkdir /var/www/nico
    mkdir /var/www/kjg
    cd ~
    
  • Download and place Alpine Linux image in /var/www/ahmedbilal-admin
    wget https://www.dropbox.com/s/5eyryhxun6847hx/alpine.zip?dl=1 -O alpine.zip
    unzip alpine.zip
    mv alpine.qcow2 /var/www/ahmedbilal-admin
    
  • Clone repos
    git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-api.git
    git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-scheduler.git
    git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-vm.git
    git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-file-scan.git
    git clone --recurse-submodules git@code.ungleich.ch:ungleich-public/ucloud-image-scanner.git
    

Put related .env inside all the above directories

  • Run "ucloud-api" as daemon
    cd ucloud-api
    pipenv install
    pipenv run gunicorn --bind [::]:80 main:app --daemon
    wget https://www.dropbox.com/s/lyu3atymxyw3846/setup.py?dl=1 -O setup.py
    pipenv run python setup.py
    cd ~
    
  • Run "ucloud-scheduler" as daemon
    cd ucloud-scheduler
    pipenv install
    pipenv run python main.py &>/dev/null &
    cd ~
    
  • Run "ucloud-vm" as daemon
    cd ucloud-vm
    pipenv install
    pipenv run python main.py /v1/host/1 --vm True &>/dev/null &
    cd ~
    
  • Install ucloud-file-scan
    cd ucloud-file-scan
    pipenv install
    cd ~
    
  • Install ucloud-image-scanner
    cd ucloud-image-scanner
    pipenv install
    cd ~
    
  • Run crontab -e and put these entries there and save by pressing Ctrl+x then y then enter
    */1 * * * * (cd /root/ucloud-file-scan && /usr/local/bin/pipenv run python main.py)
    */1 * * * * (cd /root/ucloud-image-scanner/ && /usr/local/bin/pipenv run python main.py)
    

ucloud-api

Outside world (indirect) communication with the internal systems.

Its responsibilities are
  • Create VM (Done) POST /vm/create
    {
        "name": "username",
        "realm": "user_realm",
        "seed": "user_seed",
        "specs": {
            "cpu": 16,
            "ram": 256,
            "hdd": 2000,
            "ssd": 256
        }
    }
    
  • Delete VM (Done) POST /vm/delete
    {
        "name": "username",
        "realm": "user_realm",
        "seed": "user_seed",
        "vmid": "id_of_virtual_machine" 
    }
    
  • Status VM (Done) GET /vm/status
    {
        "id": "id_of_virtual_machine" 
    }
    
  • Create new network
  • Attach network to VM
  • Detach network from VM
  • Delete network

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

/v1/vm/1
{
  "owner": "ahmedbilal-admin",
  "specs": {
    "cpu": 20,
    "ram": 2,
    "hdd": 10,
    "ssd": 10
  },
  "hostname": "",
  "status": "REQUESTED_NEW" 
}

2. Hosts Entries that look like
/v1/host/1
{
    "cpu": 32,
    "ram": 128,
    "hdd": 1024,
    "ssd": 0
    "status": "UP" 
}

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

/v1/vm/1
{
  "owner": "ahmedbilal-admin",
  "specs": {
    "cpu": 20,
    "ram": 2,
    "hdd": 10,
    "ssd": 10
  },
  "hostname": "/v1/host/1",
  "status": "REQUESTED_NEW" 
}

Note the hostname key/value pair.

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.

Updated by Nico Schottelius over 4 years ago · 7 revisions