Home Top Ad

How to setup a hypervisor in ubuntu 18.04 with KVM and Kimchi

Share:

How to install Kimchi in Ubuntu 18.04


Introduction:


In this guide, we will be making our own Hypervisor in Ubuntu 16.04 by installing KVM (Kernel-based Virtual Machine) as well as Kimchi, which is a free, open-source web-based virtualization management platform so we can manage our hypervisor easily through the web browser.


You can find more info on Kimchi here


Installing kvm
Connect to your server as the admin user via SSH.


ssh [email protected]

Update and upgrade your web server


sudo apt update && sudo apt upgrade -y

Install KVM and all dependencies required for Kimchi and Wok


sudo apt install qemu qemu-kvm libvirt-bin python-paramiko python-pil novnc python-libvirt python-ethtool python-ipaddr python-guestfs libguestfs-tools spice-html5 spice-html5 python-magic keyutils libnfsidmap2 libtirpc1 nfs-common rpcbind python-configobj python-parted -y

Note: If you receive an error about packages not found
You must enable the Universe Repository by running.


sudo add-apt-repository universe

Verify the kvm installation


$ kvm-ok

This is what you should see if KVM is supported
INFO: /dev/kvm exists
KVM acceleration can be used


Installing Kimchi:


sudo apt install nginx -y

wget https://github.com/kimchi-project/kimchi/releases/download/2.5.0/wok-2.5.0-0.noarch.deb

wget https://github.com/kimchi-project/kimchi/releases/download/2.5.0/kimchi-2.5.0-0.noarch.deb

Installing dependencies:


sudo dpkg -i wok-2.5.0-0.noarch.deb

sudo apt install -f -y

sudo dpkg --ignore-depends=python-imaging -i kimchi-2.5.0-0.noarch.deb

#reboot here
sudo shutdown -r now

#If you have UFW enabled please add the port
sudo ufw allow 8001/tcp

Fixing Problem with Kimchi Package Dependancies.


Remove python-imaging from the Kimchi dependancies, this was replaced with Python-pil and is no longer needed and must be removed to avoid the apt command from uninstalling Kimchi due to unmet dependancies.


to do this you must edit the /var/lib/dpkg/status file and find the line Package: kimchi , under this you must remove the python-imaging or rename it to python-pil in the Depends: clause as shown below



......
Package: kimchi
Status: install ok installed
Priority: optional
Section: base
Maintainer: Aline Manera [email protected]
Architecture: all
Version: 2.5.0
Depends: wok (>= 2.1.0), python-imaging, python-configobj, novnc, python-jsonschema (>= 1.3.0), python-libvirt, gettext, libvirt-bin, nfs-common, qemu-kvm, python-parted, python-psutil (>= 0.6.0), python-ethtool, sosreport, python-ipadd$
Description: Kimchi web application
Build-Depends: xsltproc,
gettext,
python-lxml
......



Now open the web interface on


https://Server_IP:8001
You should see the following
Kimchi Login
Now lets create our first VM, we need to log in using your normal ubuntu username and password.
Kimchi
For testing we will download an Ubuntu Server image to the /var/lib/kimchi/isos directory which is the default path to the ISO repository


cd /var/lib/kimchi/isos

sudo wget http://releases.ubuntu.com/16.04.2/ubuntu-16.04.2-server-amd64.iso

Now from the web interface we go to Virtualization > Templates > + Add Template


In this case i am selecting, the 16.04.2 Template and then click on Create this should add a new template as shown below
Kimchi Template


Feel free to add more ram, CPU, disk space as desired using the actions > edit button, at this point, it is just a template and not yet a vm.


Now we will create a vm using this template.


From the web interface we go to Virtualization > Guests > + Add Guest


Then we choose the VM Name and the template to use and hit create.


Important Note: Do not include any spaces in your VM name or you will be unable to start your VM.


Kimchi Add Guest


Once this is done, it is time to start your VM by pressing the Actions Menu > Start option


That's it you now have a working Ubuntu VM running, you can press the view console link to access your VM's console.


Kimchi VM


Optional Change Port to 443:


Change the port in the Nginx Config


sudo nano /etc/nginx/conf.d/wok.conf

Look for the following line


listen 0.0.0.0:8001 ssl;

Change it to


listen 0.0.0.0:443 ssl;

Also locate inside of location / config


proxy_redirect http://127.0.0.1:8010/ https://$host:8001/;

Change this to


proxy_redirect http://127.0.0.1:8010/ https://$host:443/;

Change the port in the Wok config


sudo nano /etc/wok/wok.conf

Uncomment the following line


#proxy_port = 8001

Change it to


proxy_port = 443

If you have UFW enabled please add the port


sudo ufw allow 443/tcp

Restart Wok and Nginx


sudo service wokd restart
sudo service nginx restart

That is it now you can open the web interface on


https://Server_IP

Problems you may encounter :


Fix Bug with Template creation with Ubuntu 18.04 Template


This is a bug in the current stable release that has not yet been fixed, you will see the error below when this occurs.



KCHTMPL0020E: Unable to create template due error: KCHIMG0001E: Error probing image OS information: part_list: parted print: /dev/sda: Warning: The driver descriptor says the physical block size is 2048 bytes, but Linux says it is 512 bytes.



Manual Fix


Step 1


Edit the file /usr/lib/python2.7/dist-packages/wok/plugins/kimchi/model/templates.py


Search for the line:


...
ISO_TYPE = "ISO 9660 CD-ROM"
...

Replace with


...
ISO_TYPE = ["DOS/MBR", "ISO 9660 CD-ROM"]
...

Step 2


Search for the line:


...
if ISO_TYPE in ftype:
...

Replace with
Note:(Empty characters are important)


...
iscdrom = [t for t in ISO_TYPE if t in ftype]
if iscdrom:
...

Automated


replace file with patched on from github


sudo wget -q https://raw.githubusercontent.com/kimchi-project/kimchi/1ec059af4040c50b1a7b9a34253510a46ca09d3b/model/templates.py -O /usr/lib/python2.7/dist-packages/wok/plugins/kimchi/model/templates.py 

reboot here


sudo shutdown -r now

Thats it, you should now be able to use Ubuntu 18.04 templates