C10. Ubuntu and Cloud Computing
C10. Ubuntu and Cloud Computing
C10. Ubuntu and Cloud Computing
1
CHAPTER 10
Ubuntu and Cloud Computing
2
Contents
➢Virtualization on Ubuntu
3
Cloud Computing and Virtualization
Virtualization is an important topic today, but it isn’t a difficult one to understand—at least
conceptually. We cover two distinct use cases in this chapter: server virtualization and
virtualization on the desktop. There are several scenarios, both large and small, that are
helpful to illustrate the potential of virtualization and to give the idea some definition.
For starters, imagine a large corporation or business that processes huge amounts of data.
That corporation has many dedicated computers to assist with the task. In the past, it might
have used mainframes, single computers capable of performing multiple tasks concurrently
while dealing with large data sets and multiple, concurrent users. Today, the same company
might use a server farm, a network of smaller computers that is extensible and where
specific servers in the network can be dedicated to precise tasks.
5
Virtualization on Ubuntu
6
Virtualization on Ubuntu
The problem is that some of these servers do not get used to their capacity. Take, for
example, a payroll server that might get extensive use at certain times but might sit nearly
idle at other times. That seems like a waste of resources. What if a systems administrator
could pool the resources of all these machines and then dole out those resources as they are
needed?
=> Using virtualization.
Networks of physical servers can be created using virtualization, where the physical
resources of the servers are pooled together and then passed out as designated by an
administrator. It is as if, instead of having 100 servers, each with 4 processors, 32GB of
RAM, and 1TB of physical disk storage, you now have one huge resource pool with 400
processors, 3200GB of RAM, and 100TB of disk space. Virtual machines can then use
these resources.
7
Virtualization on Ubuntu
A virtual machine (VM) is a computer that operates on top of a virtualization layer, often
called a hypervisor. It isn’t real in the sense that it runs on defined, discrete physical
resources, but it does all of the same tasks as a “real” computer. The virtualization layer on
which the VM runs defines a set of virtual interfaces for the VM, which appear to the VM’s
operating system as if they were real network cards, memory, hard drives, and so on. In a
sense, virtualization fools the guest operating system in the VM into thinking it is running
on specific physical equipment that is emulated by the virtualization software, while the
virtualization software takes care of the details of interacting with the actual hardware,
which may even change without affecting the VM. This is called hardware emulation (or
sometimes simply emulation).
8
Virtualization on Ubuntu
It is possible to create a VM and then save its image so that instead of starting with
operating system installation each time a VM is created, the VM starts up with a full
operating system and installed programs all configured to work together for a desired task.
One neat trick is to run a set of servers locally, and then add compute resources from a
cloud computing pool such as Amazon’s EC2, Ubuntu Enterprise Cloud (using
Eucalyptus), Ubuntu Cloud Infrastructure (using OpenStack), or OpenStack to start up
VMs on their network, as needed, using them while paying for the time they are running
and then deleting them (see Chapter 32, “Ubuntu and Cloud Computing”).
This saves a lot of time and money.
9
• Type 1 hypervisors are also called the “bare
metal” approach because the hypervisor is installed
Virtual Network Infrastructure directly on the hardware. Type 1 hypervisors are
Type 1 Hypervisors usually used on enterprise servers and data center
networking devices.
KVM
Kernel-based Virtual Machine (KVM) is a part of the Linux kernel. The KVM does not
perform hardware emulation but only provides the lower-level tasks. It needs a second
layer to run in user space. This is much faster than running the entire virtualization process
in user space, on top of another operating system. KVM is designed for use on processors
that have either the VT-x or AMD-V extension enabled. Managing VMs with KVM in
Ubuntu is accomplished using libvirt and QEMU.
You can check whether a system has the extensions enabled by installing and running the
kvm-ok package. It is a simple command-line tool that exits with output 0 if the system is
suitable or non-0 if not.
12
Virtualization on Ubuntu
KVM
Start by installing the following packages from the Ubuntu software repositories:
▶▶ qemu-kvm—The necessary user-space component of KVM
▶▶ libvirt-bin—A binary of a C toolkit to interact with the virtualization capabilities
of Linux that currently supports not only KVM but also Xen, VirtualBox, and more
▶▶ virtinst—A set of command-line tools for creating VMs
▶▶ bridge-utils—A set of utilities for configuring Ethernet connections in Linux
You might want to add virt-viewer, which provides a nice GUI and VNC interface to
VMs, and virt-manager, which provides a nice GUI for managing VMs. If installed, you
can find both in the Dash listing of applications.
After you install the packages, log out and back in so that the automatic addition of your
user to the libvirtd group is certain to be made effective.
13
Virtualization on Ubuntu
BRIDGED NETWORKING
To enable the use of a VM as an outside-accessible server, you need bridged networking.
This enables VMs to use a physical interface to connect to the outside network, making
them appear to the rest of the network as any other typical server.
To start, install libcap2-bin. Next, you need to grant QEMU the ability to administer
networking by setting cap_net_admin. If you have a 64-bit system, use the following:
matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu-system-x86_64
14
Virtualization on Ubuntu
BRIDGED NETWORKING
Then create a bridge interface called enp3s0 under the bridges section in /etc/
netplan/*.yaml by adding these lines to use DHCP or your network settings if you want
to configure it yourself:
network:
version: 2
renderer: networkd
ethernets:
enp3s0:
dhcp4: true
Restart networking by entering this: matthew@seymour:~$ sudo netplan apply
Finally, you need to create guest VMs that use this bridged network. Manually define your
guest OS to use the new enp3s0 interface, as you usually would in that operating system.
15
Virtualization on Ubuntu
There are several ways to create VMs for use with KVM:
One way is to use vmbuilder. This is a Python script that is best for servers on which you
intend to run a specialized, very light Ubuntu server variant that includes a tuned kernel
with only the base elements necessary to run as a virtual server, especially under KVM and
VMware. Install pythonvm-builder to get the package. You run vmbuilder from the
command line with two necessary parameters: the virtualization software and the
distribution you will run.
Instructing libvirt to inform the local virtualization environment to add the resulting VM to
the list of available virtual machines, give the new VM a specific IP address and the
hostname lovelace, and use the br0 bridge interface (Phew! That’s a lot in one
command!):
matthew@seymour:~$ sudo vmbuilder kvm ubuntu --suite bionic --flavour virtual -–arch
amd64 -o --libvirt qemu:///system --ip 192.168.0.100 --hostname lovelace --bridge br0
16
Virtualization on Ubuntu
17
Virtualization on Ubuntu
18
Virtualization on Ubuntu
VirtualBox
VirtualBox is much easier to use than KVM, especially if all you want to do is run a second
operating system on top of Ubuntu. VirtualBox runs on top of most UNIX-type operating
systems, such as Linux, BSD, and macOS (as well as on Windows).
There is a version of VirtualBox in the Ubuntu software repositories, but in general
downloading the one from the VirtualBox website is a better idea. Go to
www.virtualbox.org/wiki/Downloads.
After you’ve installed it, start VirtualBox at the command line by using the following:
matthew@seymour:~$ virtualbox
19
Virtualization on Ubuntu
Oracle VM
VirtualBox
Manager
20
Virtualization on Ubuntu
VMware
VMware is an enterprise-focused virtualization platform. The company offers a limited
feature version that runs on the desktop for free and also sells a full-featured version. It
runs well, is easy to use, and has better features than VirtualBox. It also requires buying a
new license each year, and the license isn’t cheap.
Many people consider VMware’s enterprise server offerings to be the most powerful and
well featured in the business. The VMware software runs on bare metal; it is the operating
system that gets installed on all the servers in a VMware installation. Then all the resources
are controlled from one central location. VMs can be moved while running from one
physical machine to another in the system with no loss of usability and no downtime.
21
Virtualization on Ubuntu
Xen
Xen is a well-known open source virtualization platform. It is in widespread use by
researchers, hobbyists, developers, and others. Web hosting companies that offer virtual
servers often use Xen. Generally, Xen installs on bare metal, like VMware. It can be
installed on top of another operating system in a host/guest arrangement. However, in 2008,
Ubuntu made a decision not to support Xen. Instead, the Ubuntu community has focused its
efforts on KVM. This is not a value statement that one is better than the other; it only
means that KVM seemed to be a better fit for the needs of an Ubuntu developer community
that did not have the resources to give quality support to two similar virtualization
platforms.
It appears to be possible to run Xen on Ubuntu, but there are no guarantees. In fact, most
Linux distributions have abandoned Xen for KVM now.
22
Ubuntu and Cloud Computing
Cloud computing enables you to build large, flexible systems for on-demand processing of
data. When your requirements are low, you use few resources. As the need arises, your
processes scale to use multiple systems with optimized performance according to the
requirements of the moment. This is an efficient way to use hardware and minimize waste.
Ubuntu Cloud is a stack of applications from Canonical that are included in the Ubuntu
Server Edition. These applications make it easy to install and configure an Ubuntubased
cloud. The software is free and open source, but Canonical offers paid technical
support.
23
Ubuntu and Cloud Computing
24
Virtualization on Ubuntu
25
Virtualization on Ubuntu
26
Virtualization on Ubuntu
27
Virtualization on Ubuntu
Generally, the only other step available beyond IaaS is traditional server building, where
you are responsible for the physical machine and everything on it. However, Ubuntu has
added another service to the list: metal as a service (MaaS), which is designed to bring the
language of the cloud to physical servers. Their goal is to make it as easy to set up the
physical hardware, deploy your app or service, and scale up or down dynamically as it is
in the cloud. The server is installed on the physical hardware and then managed using
one web interface to manage all the various machines. Learn more at https://maas.io/.
28
Virtualization on Ubuntu
29
Virtualization on Ubuntu
OpenStack
OpenStack is an Apache-licensed cloud computing platform. It was founded as a
collaboration between NASA and Rackspace. After less than a year, it boasted a worldwide
community of developers. Adoption has been swift, and already many large corporations,
universities, and institutions are using OpenStack for cloud computing. Ubuntu and
OpenStack have worked closely together for a long time and have similar release
schedules, and Ubuntu is the reference operating system for OpenStack.
30
Virtualization on Ubuntu
Amazon Web Services (AWS) is a mature, enterprise-quality cloud provider that has been
around since the beginning. It hosts giants like Netflix and PayPal. It has tons of features,
options, tools, and can be intimidating at first. It is the main cloud provider today with
a number of accounts that far surpasses any competitor. It can handle any configuration
you want or need and comes with great documentation and support. Ubuntu images are
available in AWS for immediate deployment, making it quick and easy to get started.
Learn more at https://aws.amazon.com/.
31
Virtualization on Ubuntu
Google Cloud
Google Cloud is the second most popular cloud and also hosts some big clients like
Target and the Home Depot. As with AWS, it is a mature offering with a rich toolset and
myriad options available. Ubuntu images are also available in Google Cloud for immediate
deployment. Learn more at https://cloud.google.com/.
32
Virtualization on Ubuntu
Microsoft Azure
Microsoft entered the cloud services competition a bit later than the other two big names,
but it has done so with gusto. Azure is a cloud provider boasting more deployment/hosting
regions than any other provider. It includes a strong toolset and also has Ubuntu images
available for immediate deployment. Learn more at https://azure.microsoft.com/.
33
Cloud Models
Cloud Models
There are four primary cloud models:
• Public clouds - Cloud-based applications and services made available to the general population.
• Private clouds - Cloud-based applications and services intended for a specific organization or
entity, such as the government.
• Hybrid clouds - A hybrid cloud is made up of two or more clouds (example: part private, part
public), where each part remains a separate object, but both are connected using a single
architecture.
• Community clouds - A community cloud is created for exclusive use by a specific community.
The differences between public clouds and community clouds are the functional needs that have
been customized for the community. For example, healthcare organizations must remain
compliant with policies and laws (e.g., HIPAA) that require special authentication and
confidentiality.
Virtualization on Ubuntu