C10. Ubuntu and Cloud Computing

Download as pdf or txt
Download as pdf or txt
You are on page 1of 37

LINUX AND

OPEN SOURCE SOFTWARE


Ubuntu Linux Unleashed 2021 Edition (Matthew Helmke) (z-lib.org)

1
CHAPTER 10
Ubuntu and Cloud Computing

2
Contents

➢Virtualization on Ubuntu

➢Ubuntu and Cloud Computing

3
Cloud Computing and Virtualization

Virtualization separates the operating


system (OS) from the hardware. Various
providers offer virtual cloud services that can
dynamically provision servers as required.
For example, Amazon Web Services (AWS)
provides a simple way for customers to
dynamically provision the compute resources
they need. These virtualized instances of
servers are created on demand. As shown in
the figure, the network administrator can
deploy a variety of services from the AWS
Management Console including virtual
machines, web applications, virtual servers,
and connections to IoT devices.
4
Virtualization on Ubuntu

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.

• With Type 1 hypervisors, the hypervisor is installed


directly on the server or networking hardware.
Then, instances of an OS are installed on the
hypervisor, as shown in the figure. Type 1
hypervisors have direct access to the hardware
resources. Therefore, they are more efficient than
hosted architectures. Type 1 hypervisors improve
scalability, performance, and robustness.
Virtual Network Infrastructure • A Type 2 hypervisor is software that creates
Type 2 Hypervisors and runs VM instances. The computer, on
which a hypervisor is supporting one or more
VMs, is a host machine. Type 2 hypervisors
are also called hosted hypervisors.
• A big advantage of Type 2 hypervisors is that
management console software is not
required.
Virtualization on Ubuntu

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

• If you have a 32-bit system:


matthew@seymour:~$ sudo setcap cap_net_admin=ei /usr/bin/qemu

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

To copy a virtual machine, use virt-clone:


matthew@seymour:~$ sudo virt-clone -o hopper -n knuth -f /var/lib/libvirt/
imagzes/knuth.img –connect=qemu:///system
This example includes the following options:
▶▶ -o hopper—Defines the name of the origin or source VM
▶▶ -n knuth—Defines the name of the new VM
▶▶ -f—Defines the path to the file, partition, or logical volume that the new VM will
use
▶▶ --connect—Defines the hypervisor to use

17
Virtualization on Ubuntu

To start a virtual machine, use the following:


matthew@seymour:~$ virsh -c qemu:///system start hopper
To stop a virtual machine, use this:
matthew@seymour:~$ virsh -c qemu:///system shutdown hopper
When a VM is installed and running, you can connect to it by using the configured IP
address and a utility like ssh. You can also use a GUI with the following:
matthew@seymour:~$ virt-viewer -c qemu:///system hopper
You may use a GUI to manage your VMs by connecting to the following:
matthew@seymour:~$ virt-manager -c qemu:///system

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

Cloud services are available in


a variety of options, tailored to
meet customer requirements.
The three main cloud computing
services defined by the National
Institute of Standards and
Technology (NIST) in their
Special Publication 800-145 are
as follows:

24
Virtualization on Ubuntu

Software as a Service (SaaS)


SaaS is sometimes referred to as on-demand software. In this service model, the software
application and its related data are moved to the cloud. Access is generally through a web
browser, although a thin client and server configuration may also be used. Someone else
takes care of everything else. This is kind of like renting a hotel room: Everything is
provided and set up for you, and you just enjoy and use it for a specific need. Some
examples of SaaS include email hosts like Yahoo! Mail, services like Google Docs, web
games, and customer relationship management (CRM) software.

25
Virtualization on Ubuntu

Platform as a Service (PaaS)


PaaS takes things a step further than SaaS. In this service model, an entire computing
platform is provided in the cloud. It’s basically paying to run your containers on someone
else’s container platform. This typically includes the operating system, programming
language interpreters or execution environments, databases, web servers, and so on.
These facets are accessed directly for computing platform maintenance, using provider
portals, application programming interfaces (APIs), software development kits (SDKs),
or services like SSH. What is built on the platform is then accessed by the end user the
same way it would be accessed if it were running on a locally owned and operated piece
of hardware or hardware that’s running in a large data center.

26
Virtualization on Ubuntu

Infrastructure as a Service (IaaS)


IaaS goes even further than PaaS. In this service model, you transition your entire server
to the cloud. Your provider offers computers, typically virtual ones, on which you can
install any operating system (perhaps within a set menu the provider allows), and you can
configure it as you like. Someone else takes care of the physical machines and networks,
and you take care of all the rest. IaaS is like buying a condominium: You own it and can do
whatever you want inside it, but someone else takes care of the grounds and landscaping.

27
Virtualization on Ubuntu

Metal as a Service (MaaS)

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

Ubuntu on the Public Cloud


There are several options to choose from when looking to move to cloud computing.
Each has its unique methodologies, strengths, and command set. An in-depth study of each
is beyond the scope of this book, but we are able to present a description of the big players
providing public cloud access in North America and Europe (in Asia, look into Alibaba
Cloud at https://us.alibabacloud.com/).
All of them are pay-to-play and use proprietary software, with the exception of
OpenStack, but OpenStack is designed primarily as the foundation for a private cloud and
requires a place for you to host it, such as your own data center or one of the providers they
mention in the following link: https://ubuntu.com/public-cloud

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

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

Cloud Computing versus Data Center


The terms data center and cloud computing are often used incorrectly. These are the correct
definitions of data center and cloud computing:
Data center: Typically, a data storage and processing facility run by an in-house IT
department or leased offsite.
Cloud computing: Typically, an off-premise service that offers on-demand access to a
shared pool of configurable computing resources. These resources can be rapidly
provisioned and released with minimal management effort.
Data centers are the physical facilities that provide the compute, network, and storage
needs of cloud computing services. Cloud service providers use data centers to host their
cloud services and cloud-based resources.
https://www.youtube.com/watch?v=M988_fsOSWo
https://www.ibm.com/cloud/learn/cloud-computing
36

You might also like