Home Management ToolsCockpit Manage KVM Virtual Machines Using Cockpit Web Console
Manage KVM Virtual Machines Using Cockpit Web Console

Manage KVM Virtual Machines Using Cockpit Web Console

By sk
756 Views

Cockpit doesn't require any introduction. If you are a Linux admin, you should've definitely used it or at least heard of it. Cockpit is a free, open source web-based server administration tool used to monitor and administer Linux servers via a web browser. In this guide, we will see how to manage KVM virtual machines using Cockpit web console interface.

Prerequisites

Obviously, you should have installed KVM in your Linux server. The following guides explains how to install and configure KVM in CentOS 8 and Ubuntu 20.04 LTS server editions.

Next, you need to install Cockpit on your KVM host. Refer the following guide to install and configure Cockpit on different Linux distros.

Make sure you have installed "cockpit-machines" package, which gives the ability to manage VMs via a web browser.

Optionally, you can install Virt-viewer application if you want the ability to open a graphical console in your remote desktop client. Virt-viewer is available for most operating systems.

To install virt-viewer on RHEL, CentOS, run:

$ sudo yum install virt-viewer

On Fedora:

$ sudo dnf install virt-viewer

On Ubuntu, Debian:

$ sudo apt-get install virt-viewer

Manage KVM Virtual Machines Using Cockpit Web Console

Open your web browser and log in to Cockpit console bay navigating to http://IP-address:9090 from the address bar.

Log in to Cockpit web console

In CentOS 8 system, the Cockpit login console should look like below:

Cockpit login console in CentOS 8

You should now see a tab named "Virtual Machines" on the left pane. Click on it to view the list of available Kvm guest systems on the right side.

Manage kvm virtual machines using cockpit web console

From here, we can manage all virtual machine management tasks such as,

  • View the list of available virtual machines,
  • View the details of a virtual machine,
  • Edit the virtual machine parameters such as memory, disk and network interfaces etc.,
  • Create a new VM,
  • Import a VM,
  • Run a VM,
  • Delete a VM,
  • View storage pools,
  • Create a new network pool,
  • Edit storage pools,
  • View KVM default virtual networks,
  • Edit networks,
  • Create a new virtual network etc.

Create a new KVM virtual machine

To create a kvm guest, click on the "Create VM" button in the Virtual machines section.

Create new kvm virtual machine from cockpit

Fill up the the virtual machine details:

Enter virtual machine details

  • Name - Virtual machine name, for example Archlinux,
  • Installation type - I already have the ISO image of the Arch linux OS, so choose Local Install Media. If you don't have ISO, choose download ISO option. The appropriate ISO will be downloaded.
  • Operating System - The actual operating system type that you want to install on your kvm guest. Pick the OS you want to install from the drop-down list.
  • Storage - Choose the disk storage (hard drive) for your guest. I don't have any existing hdd, so I choose "Create New Volume" option from the drop down list. Enter the size of your hdd or use the slider to select disk volume size.
  • Memory - Choose the RAM size for your guest.

The last two are optional. I am going to uncheck these options, because I don't want to start the guest OS installation immediately. Once you entered all required details, click on "Create VM" at the bottom.

You will now see the overview of your new VM. Make sure all the selected parameters are correct.

Overview of a new kvm virtual machine

Apart from the overview tab, there are a few other tabs exists:

  • Usage - Shows the usage details memory and vCPU of a running VM.
  • Disks - Shows the list of attached disk and cdrom details. In this tab, we can edit the disk, cdrom parameters, add new disk and delete the existing drives.
  • Network Interfaces - Shows the network card interface details. In this tab, we we can create a new network interface, edit the exiting network card and unplug the attached network card etc.
  • Consoles - In this section, we can choose different ways to access a console on the VM such as,
    • using the web-based Graphics Console (VNC),
    • the Graphics Console in Desktop Viewer (which uses virt-viewer),
    • or the Serial Console.

The only setting you might probably want to configure mostly is the network settings. By default, KVM chooses its default network. If you want to access the VM from other remote hosts outside the network, you need to choose the bridged network (br0).

To do so, go to "Network Interfaces" tab and click "Edit" button:

Edit virtual machine network settings in Cockpit console

Select the Interface Type as "Bridge To LAN" Or "Direct attachment" and choose Source as "br0". You can also choose your KVM host's physical network interface, for example enp0s3. Finally click Save.

Select bridge networking for Kvm virtual machines in Cockpit

Now start the guest OS installation by clicking on the "Install" button.

Start Guest OS installation on Kvm host via Cockpit

Once you clicked the Install button, you will be taken to the the guess OS installation window shown under the "Consoles" section in the Cockpit interface. Make sure you have chosen "Graphics Console (VNC)" as your Console type.

Installing OS on Kvm guest via Cockpit

Now continue the guest OS installation as usual.

You can also access the guest machines using any VNC applications as described under "Access Virtual machines from remote systems via VNC client" section in the Kvm installation guide linked above.

Import VMs

If you already have created VMs, Cockpit has an option to import them. To do so, click on the "Import VM" option under the "Virtual Machines" tab. Enter the name to the VM, choose the existing disk image location on the host's file system, select the operating system type and memory size. Finally, click Import button.

Import virtual machines via Cockpit

Restart / Pause/ Shutdown Kvm guests

No need to memorize the virsh commands. We can reboot, suspend and power off KVM virtual machines right from the Cockpit interface.

Restart Kvm guests via Cockpit

Configure KVM storage pools

On the top of the Virtual Machines section, you will see the following two sub-sections:

  1. Storage pools
  2. Networks

In the Storage pools section, we configure the storage path of all virtual machines. By default, all the virtual machine's disk files are stored under /var/lib/libvirt/images location.

You can create a new storage pool in anywhere in the file system. A storage pool's type can be a;

  • Filesystem directory,
  • Network file system,
  • iSCSI target / iSCSI directory target,
  • Physical disk device,
  • LVM volume group.

KVM storage pools in Cockpit

As you can see, I have created two storage pools. Click on a pool to view its details. If you don't need a storage, either deactivate it temporarily or completely delete it.

Configure KVM virtual networks

By default KVM creates a private virtual bridge named virbr0 to let all VMs to connect with one another, within the host computer. The kvm default bridge provides its own subnet and DHCP to configure the guest’s network and uses NAT to access the host network.

You can configure as many virtual networks as you want. I already have configured a bridge network to allow a kvm guests to use same IP range of the host system.

Configure KVM networks in Cockpit

Under Networks section, we can,

  • view the IP address details of a network,
  • create a new virtual network,
  • deactivate a network,
  • and delete a network.

Conclusion

Managing Kvm guests via Cockpit is very easy! No need to memorize the commands. Cockpit has simple web interface that allows us to do basic KVM management operations from a web browser with a couple mouse clicks.

Related read:

Thanks for stopping by!

Help us to help you:

Have a Good day!!

You May Also Like

5 comments

Jalal July 7, 2020 - 7:18 pm

Hi,
Thanks a lot
Good & useful article

Reply
Christoph July 11, 2020 - 6:37 pm

Thanks for the detailed explanations! I’m having difficulties with the bidged network mode, though. You state that I should ” “choose Source as ‘br0′”, but I don’t have br0 as an option in the source dropdown menu. I suppose the bridge has to be created first. But how do I create a bridge in Cockpit?

Reply
sk July 11, 2020 - 7:08 pm

You don’t have to choose bridge network unless you want to access the VM from remote systems other than the KVM host. Just leave the defaults and create VM as usual. If you still want to create bridge network, I have documented the steps to create bridge networking in the first article of this series here-> https://ostechnix.com/install-and-configure-kvm-in-ubuntu-20-04-headless-server/

Reply
Christoph July 11, 2020 - 7:19 pm

Thanks for the super fast reply! Okay, so you have to create the bridge outside of cockpit.

My assumption was that cockpit provides a ui that lets you do manage your vms through a gui. I don’t quite understand how they can offer an option “Bridge to LAN” when you can’t use it without creating the bridge outside of Cockpit. Maybe I’m asking too much, but this kind of pitfall should at least be documented in the ui…

Thanks again for your excellent tutorial!

Reply
sk July 11, 2020 - 9:22 pm

Yes, you need to configure KVM bridge outside of Cockpit.

Reply

Leave a Comment

* By using this form you agree with the storage and handling of your data by this website.

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

This website uses cookies to improve your experience. We'll assume you're ok with this, but you can opt-out if you wish. Accept Read More