“Install & Configure KVM on Host Machine – PART 4/6″

MAAS

The starting point our lab is the following:

1 STEP – PREPARE HOST SERVER

For our lab we’ll be realized on a host IBM System x3650 with Ubuntu 18.04 LTS installed and  where will run our virtual environment.

1.1 STEP – INSTALL UBUNTU 18.04 LTS ON HOST SERVER

use this guide to proceed

Ubuntu 18.04 LTS Server Editiion

for our case we need two cabled network ports and  their’s own network parameters are:

hostname: maas

IP Address (eno2): 10.20.81.2

IP Address (eno3): 10.20.82.2

1.2 STEP – INSTALL KVM (KERNEL-BASED VIRTUAL MACHINE) ON HOST

KVM (for Kernel-based Virtual Machine) is a full virtualization solution for Linux on x86 hardware containing virtualization extensions (Intel VT or AMD-V), for our goal we’ve installed that on NODE as hypervisor by that :

$: sudo apt install bidge-utils qemu-kvm libvirt-bin virtinst 

Once we’re done we can verify the install is successful by running

$: kvm-ok
INFO: /dev/kvm exists
KVM acceleration can be used

Restart our server so that the needed kvm and libvirt deamons come up.

1.3 STEP – CONFIGURE SSH KEYPAIR ON MAAS SERVER

We’ve to go back on our MAAS Server and run the following command:

$: sudo chsh -s /bin/bash maas
$: sudo su - maas
$: ssh-keygen -f ~/.ssh/id_rsa -N ''
Generating public/private rsa key pair.
Created directory '/var/lib/maas/.ssh'.
Your identification has been saved in /var/lib/maas/.ssh/id_rsa.
Your public key has been saved in /var/lib/maas/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:ArHr/dnnBmehQxJOTOx3UGRuAf4bvl8WSZgCqQNlGd8 maas@HUBMAAS
The key's randomart image is:
+---[RSA 2048]----+
|    . .B+.o+=    |
|     +..*o+o .o  |
|    o .+.o.Eoo . |
|     o o+ oo+ . .|
|    . . S+ oo. o |
|   . . .  +.oo  .|
|    . .    =o   o|
|       . o  o. o |
|        o .+o..  |
+----[SHA256]-----+

then add the public key to file /home//.ssh/authorized_keys on the KVM host:

$: ssh-copy-id -i ~/.ssh/id_rsa @

Where $KVM_HOST represents the IP address of the KVM host and $USER represents a user on the KVM host with the permission to communicate with the libvirt daemon. The latter is achieved via group membership, typically the libvirtd group.

$: ssh-copy-id -i ~/.ssh/id_rsa richardsith@10.20.81.2
/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/var/lib/maas/.ssh/id_rsa.pub"
The authenticity of host '10.20.253.180 (10.20.253.180)' can't be established.
ECDSA key fingerprint is SHA256:7sjsDkvRW+0tDUDFci/+UQb4qxLC1+fZv3lSxM6h7bg.
Are you sure you want to continue connecting (yes/no)? yes
+ù/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed
/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys
richardsith@10.20.253.180's password: 

Number of key(s) added: 1

Now try logging into the machine, with:   "ssh 'richardsith@10.20.253.180'"
and check to make sure that only the key(s) you wanted were added.

now as user ‘maas’, test connecting to the KVM host with virsh:

$: virsh -c qemu+ssh://@/system list --all

for our lab is that

$: virsh -c qemu+ssh://richardsith@10.20.81.2/system list --all
 Id    Name                           State
----------------------------------------------------
$: exit

1.4 STEP – CREATE BRIDGE NETWORKING ON HOST SERVER

Now on our Host we need to install the following packages:

$: sudo modprobe vhost_net 
$: sudo  lsmod | grep vhost 
vhost_net              20480  0
vhost                  32768  1 vhost_net
macvtap                20480  1 vhost_net

$:  sudo nano /etc/modules 

and adding the line

vhost

then edit  /etc/netplan/01-netcfg.yaml and modify that like this:

# This file describes the network interfaces available on your system
# For more information, see netplan(5).
network:
  version: 2
  renderer: networkd
  ethernets:
    eno2:
      dhcp4: no
      dhcp6: no
    eno3:
      dhcp4: no
      dhcp6: no
  bridges:
    br0:
      interfaces: [eno2]
      dhcp4: no
      dhcp6: no
      addresses: [10.20.81.2/24]
      gateway4: 10.20.81.254
      nameservers:
        addresses: [10.20.81.1]
      parameters:
        stp: false
    br1:
      interfaces: [eno3]
      dhcp4: no
      dhcp6: no
      addresses: [10.20.82.2/24]

to end that run

$: sudo netplan try
$: sudo netplan apply

At this point our environment is almost ready, we need now to create the VM. To make that we have two way:

note: If you are following the guide dedicate to “Ubuntu Maas, Juju, Landscape and Openstack Cloud with Ubuntu 18.04 LTS Server Edition”  continue with the second part here.

The third part is done see you to next one.

<- part 2/6 .


“cya to the next 1…. Njoy !”

bye dakj

Disclaimer: All the tutorials included on this site are performed in a lab environment to simulate a real world production scenario. As everything is done to provide the most accurate steps to date, we take no responsibility if you implement any of these steps in a production environment.

“We learn from our mistakes”

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.