forked from uncloud/uncloud
Efforts to make ucloud a python package
This commit is contained in:
parent
bbe09667a6
commit
1e7300b56e
71 changed files with 241 additions and 1043 deletions
|
|
@ -0,0 +1,53 @@
|
|||
How to create VM images for ucloud
|
||||
==================================
|
||||
|
||||
Overview
|
||||
---------
|
||||
|
||||
ucloud tries to be least invasise towards VMs and only require
|
||||
strictly necessary changes for running in a virtualised
|
||||
environment. This includes configurations for:
|
||||
|
||||
* Configuring the network
|
||||
* Managing access via ssh keys
|
||||
* Resizing the attached disk(s)
|
||||
|
||||
|
||||
Network configuration
|
||||
---------------------
|
||||
All VMs in ucloud are required to support IPv6. The primary network
|
||||
configuration is always done using SLAAC. A VM thus needs only to be
|
||||
configured to
|
||||
|
||||
* accept router advertisements on all network interfaces
|
||||
* use the router advertisements to configure the network interfaces
|
||||
* accept the DNS entries from the router advertisements
|
||||
|
||||
|
||||
Configuring SSH keys
|
||||
--------------------
|
||||
|
||||
To be able to access the VM, ucloud support provisioning SSH keys.
|
||||
|
||||
To accept ssh keys in your VM, request the URL
|
||||
*http://metadata/ssh_keys*. Add the content to the appropriate user's
|
||||
**authorized_keys** file. Below you find sample code to accomplish
|
||||
this task:
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
tmp=$(mktemp)
|
||||
curl -s http://metadata/ssk_keys > "$tmp"
|
||||
touch ~/.ssh/authorized_keys # ensure it exists
|
||||
cat ~/.ssh/authorized_keys >> "$tmp"
|
||||
sort "$tmp" | uniq > ~/.ssh/authorized_keys
|
||||
|
||||
|
||||
Disk resize
|
||||
-----------
|
||||
In virtualised environments, the disk sizes might grow. The operating
|
||||
system should detect disks that are bigger than the existing partition
|
||||
table and resize accordingly. This task is os specific.
|
||||
|
||||
ucloud does not support shrinking disks due to the complexity and
|
||||
intra OS dependencies.
|
||||
155
ucloud/docs/source/usage/usage-for-admins.rst
Normal file
155
ucloud/docs/source/usage/usage-for-admins.rst
Normal file
|
|
@ -0,0 +1,155 @@
|
|||
Usage Guide For Administrators
|
||||
==============================
|
||||
|
||||
Start API
|
||||
----------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud api
|
||||
|
||||
Host Creation
|
||||
-------------
|
||||
|
||||
Currently, we don't have any host (that runs virtual machines).
|
||||
So, we need to create it by executing the following command
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli host create --hostname ungleich.ch --cpu 32 --ram '32GB' --os-ssd '32GB'
|
||||
|
||||
You should see something like the following
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"message": "Host Created"
|
||||
}
|
||||
|
||||
Start Scheduler
|
||||
---------------
|
||||
Scheduler is responsible for scheduling VMs on appropriate host.
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud scheduler
|
||||
|
||||
Start Host
|
||||
----------
|
||||
Host is responsible for handling the following actions
|
||||
|
||||
* Start VM.
|
||||
* Stop VM.
|
||||
* Create VM.
|
||||
* Delete VM.
|
||||
* Migrate VM.
|
||||
* Manage Network Resources needed by VMs.
|
||||
|
||||
It uses a hypervisor such as QEMU to perform these actions.
|
||||
|
||||
To start host we created earlier, execute the following command
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud host ungleich.ch
|
||||
|
||||
Create OS Image
|
||||
---------------
|
||||
|
||||
Create ucloud-init ready OS image (Optional)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
This step is optional if you just want to test ucloud. However, sooner or later
|
||||
you want to create OS images with ucloud-init to properly
|
||||
contexualize VMs.
|
||||
|
||||
1. Start a VM with OS image on which you want to install ucloud-init
|
||||
2. Execute the following command on the started VM
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
apk add git
|
||||
git clone https://code.ungleich.ch/ucloud/ucloud-init.git
|
||||
cd ucloud-init
|
||||
sh ./install.sh
|
||||
3. Congratulations. Your image is now ucloud-init ready.
|
||||
|
||||
|
||||
Upload Sample OS Image
|
||||
~~~~~~~~~~~~~~~~~~~~~~
|
||||
Execute the following to get the sample OS image file.
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
mkdir /var/www/admin
|
||||
(cd /var/www/admin && wget https://cloud.ungleich.ch/s/qTb5dFYW5ii8KsD/download)
|
||||
|
||||
Run File Scanner and Image Scanner
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
Currently, our uploaded file *alpine-untouched.qcow2* is not tracked by ucloud. We can only make
|
||||
images from tracked files. So, we need to track the file by running File Scanner
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud filescanner
|
||||
|
||||
File Scanner would run, scan your uploaded image and track it. You can check whether your image
|
||||
is successfully tracked by executing the :code:`ucloud-cli user files`, It will return something like the following
|
||||
|
||||
.. _list-user-files:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"message": [
|
||||
{
|
||||
"filename": "alpine-untouched.qcow2",
|
||||
"uuid": "3f75bd20-45d6-4013-89c4-7fceaedc8dda"
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Our file is now being tracked by ucloud. Lets create an OS image using the uploaded file.
|
||||
|
||||
An image belongs to an image store. There are two types of store
|
||||
|
||||
* Public Image Store
|
||||
* Private Image Store (Not Implemented Yet)
|
||||
|
||||
.. note::
|
||||
**Quick Quiz** Have we created an image store yet?
|
||||
|
||||
The answer is **No, we haven't**. Creating a sample image store is very easy.
|
||||
Just execute the following command
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
(cd ~/ucloud && pipenv run python api/create_image_store.py)
|
||||
|
||||
An image store (with name = "images") would be created. Now, we are fully ready for creating our
|
||||
very own image. Executing the following command to create image using the file uploaded earlier
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli image create-from-file --name alpine --uuid 3f75bd20-45d6-4013-89c4-7fceaedc8dda --image-store-name images
|
||||
|
||||
Please note that your **uuid** would be different. See :ref:`List of user files <list-user-files>`.
|
||||
|
||||
Now, ucloud have received our request to create an image from file. We have to run Image Scanner to make the image.
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud imagescanner
|
||||
|
||||
To make sure, that our image is create run :code:`ucloud-cli image list --public`. You would get
|
||||
output something like the following
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"images": [
|
||||
{
|
||||
"name": "images:alpine",
|
||||
"status": "CREATED"
|
||||
}
|
||||
]
|
||||
}
|
||||
119
ucloud/docs/source/usage/usage-for-users.rst
Normal file
119
ucloud/docs/source/usage/usage-for-users.rst
Normal file
|
|
@ -0,0 +1,119 @@
|
|||
Usage Guide For End Users
|
||||
=========================
|
||||
|
||||
Create VM
|
||||
---------
|
||||
|
||||
The following command would create a Virtual Machine (name: meow)
|
||||
with following specs
|
||||
|
||||
* CPU: 1
|
||||
* RAM: 1GB
|
||||
* OS-SSD: 4GB
|
||||
* OS: Alpine Linux
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli vm create --vm-name meow --cpu 1 --ram '1gb' --os-ssd '4gb' --image images:alpine
|
||||
|
||||
|
||||
.. _how-to-check-vm-status:
|
||||
|
||||
Check VM Status
|
||||
---------------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli vm status --vm-name meow
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
{
|
||||
"hostname": "/v1/host/74c21c332f664972bf5078e8de080eea",
|
||||
"image_uuid": "3f75bd20-45d6-4013-89c4-7fceaedc8dda",
|
||||
"in_migration": null,
|
||||
"log": [
|
||||
"2019-11-12T09:11:09.800798 - Started successfully"
|
||||
],
|
||||
"metadata": {
|
||||
"ssh-keys": []
|
||||
},
|
||||
"name": "meow",
|
||||
"network": [],
|
||||
"owner": "admin",
|
||||
"owner_realm": "ungleich-admin",
|
||||
"specs": {
|
||||
"cpu": 1,
|
||||
"hdd": [],
|
||||
"os-ssd": "4.0 GB",
|
||||
"ram": "1.0 GB"
|
||||
},
|
||||
"status": "RUNNING",
|
||||
"vnc_socket": "/tmp/tmpj1k6sdo_"
|
||||
}
|
||||
|
||||
|
||||
Connect to VM using VNC
|
||||
-----------------------
|
||||
|
||||
We would need **socat** utility and a remote desktop client
|
||||
e.g Remmina, KRDC etc. We can get the vnc socket path by getting
|
||||
its status, see :ref:`how-to-check-vm-status`.
|
||||
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
socat TCP-LISTEN:1234,reuseaddr,fork UNIX-CLIENT:/tmp/tmpj1k6sdo_
|
||||
|
||||
|
||||
Then, launch your remote desktop client and connect to vnc://localhost:1234.
|
||||
|
||||
Create Network
|
||||
--------------
|
||||
|
||||
Layer 2 Network with sample IPv6 range fd00::/64 (without IPAM and routing)
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli network create --network-name mynet --network-type vxlan
|
||||
|
||||
|
||||
Layer 2 Network with /64 network with automatic IPAM
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli network create --network-name mynet --network-type vxlan --user True
|
||||
|
||||
Attach Network to VM
|
||||
--------------------
|
||||
|
||||
Currently, user can only attach network to his/her VM at
|
||||
the time of creation. A sample command to create VM with
|
||||
a network is as follow
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli vm create --vm-name meow2 --cpu 1 --ram '1gb' --os-ssd '4gb' --image images:alpine --network mynet
|
||||
|
||||
.. _get-list-of-hosts:
|
||||
|
||||
Get List of Hosts
|
||||
-----------------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli host list
|
||||
|
||||
|
||||
Migrate VM
|
||||
----------
|
||||
|
||||
.. code-block:: sh
|
||||
|
||||
ucloud-cli vm migrate --vm-name meow --destination server1.place10
|
||||
|
||||
|
||||
.. option:: --destination
|
||||
|
||||
The name of destination host. You can find a list of host
|
||||
using :ref:`get-list-of-hosts`
|
||||
Loading…
Add table
Add a link
Reference in a new issue