Book Image

Mastering KVM Virtualization - Second Edition

By : Vedran Dakic, Humble Devassy Chirammal, Prasad Mukhedkar, Anil Vettathu
5 (1)
Book Image

Mastering KVM Virtualization - Second Edition

5 (1)
By: Vedran Dakic, Humble Devassy Chirammal, Prasad Mukhedkar, Anil Vettathu

Overview of this book

Kernel-based Virtual Machine (KVM) enables you to virtualize your data center by transforming your Linux operating system into a powerful hypervisor that allows you to manage multiple operating systems with minimal fuss. With this book, you'll gain insights into configuring, troubleshooting, and fixing bugs in KVM virtualization and related software. This second edition of Mastering KVM Virtualization is updated to cover the latest developments in the core KVM components - libvirt and QEMU. Starting with the basics of Linux virtualization, you'll explore VM lifecycle management and migration techniques. You’ll then learn how to use SPICE and VNC protocols while creating VMs and discover best practices for using snapshots. As you progress, you'll integrate third-party tools with Ansible for automation and orchestration. You’ll also learn to scale out and monitor your environments, and will cover oVirt, OpenStack, Eucalyptus, AWS, and ELK stack. Throughout the book, you’ll find out more about tools such as Cloud-Init and Cloudbase-Init. Finally, you'll be taken through the performance tuning and troubleshooting guidelines for KVM-based virtual machines and a hypervisor. By the end of this book, you'll be well-versed with KVM virtualization and the tools and technologies needed to build and manage diverse virtualization environments.
Table of Contents (22 chapters)
1
Section 1: KVM Virtualization Basics
4
Section 2: libvirt and ovirt for Virtual Machine Management
11
Section 3: Automation, Customization, and Orchestration for KVM VMs
15
Section 4: Scalability, Monitoring, Performance Tuning, and Troubleshooting

What this book covers

Chapter 1, Understanding Linux Virtualization, discusses different types of virtualization, hypervisor types, and Linux virtualization concepts (Xen and KVM). In this chapter, we try to explain some basics of Linux virtualization and how it fits into the cloud environment from a high-level perspective.

Chapter 2, KVM as a Virtualization Solution, starts with a discussion of virtualization concepts and the need to virtualize our environments, explains the basic hardware and software aspects of virtualization, and the various approaches to virtualization. In this chapter, we start discussing KVM and libvirt, concepts that we'll use throughout this book.

Chapter 3, Installing KVM Hypervisor, libvirt, and oVirt, expands on Chapter 2 by introducing some new concepts including oVirt, a GUI that can be used to manage our virtualized Linux infrastructure. We take you through the process of checking whether the hardware used is compatible with KVM, introduce some basic commands for virtual machine deployment, and then move on to explain how we'd use oVirt in the same scenario.

Chapter 4, Libvirt Networking, explains how libvirt interacts with various networking concepts – virtual switches in different modes, how to use CLI tools to manage libvirt networking, TAP and TUN devices, Linux bridging, and Open vSwitch. After that, we discuss more extreme examples of networking by using SR-IOV, a concept that should get us the lowest latency and highest throughput and is used in cases where every single millisecond counts.

Chapter 5, Libvirt Storage, is a big one, as storage concepts are extremely important when building virtualized and cloud environments. We discuss every type of storage that KVM supports – local storage pools, NFS, iSCSI, SAN, Ceph, Gluster, multipathing and redundancy, virtual disk types, and so on. We also offer you a glimpse into the future of storage – with NVMe and NVMeoF being some of the technologies discussed.

Chapter 6, Virtual Display Devices and Protocols, talks about various virtual machine display types, remote protocols including VNC and Spice, as well as NoVNC, which ensures display portability as we can use a virtual machine console inside a web browser by using NoVNC.

Chapter 7, Virtual Machines: Installation, Configuration, and Life Cycle Management, introduces additional ways of deploying and configuring KVM virtual machines, as well as migration processes, which are very important for any kind of production environment.

Chapter 8, Creating and Modifying VM Disks, Templates, and Snapshots, discusses various virtual machine image types, virtual machine templating processes, the use of snapshots, and some of the use cases and best practices while using snapshots. It also serves as an introduction to the next chapter, where we will be using templating and virtual machine disks in a much more streamlined fashion to customize virtual machines post-boot by using cloud-init and cloudbase-init.

Chapter 9, Customize a Virtual Machine with cloud-init, discusses one of the most fundamental concepts in cloud environments – how to customize a virtual machine image/template post-boot. Cloud-init is used in almost all of the cloud environments to do post-boot Linux virtual machine configuration, and we explain how it works and how to make it work in your environment.

Chapter 10, Automated Windows Guest Deployment and Customization, is a continuation of Chapter 9, with a razor-sharp focus on Microsoft Windows virtual machine templatization and post-boot customization. For that, we use cloudbase-init, a concept that's basically the same as cloud-init, but which is suited for Microsoft-based operating systems only.

Chapter 11, Ansible and Scripting for Orchestration and Automation, takes us on the first part of the Ansible journey – deploying AWX and Ansible, and describes how to use these concepts in our KVM-based environments. This is just one of the Ansible usage models that is employed in modern-day IT, as the whole DevOps and infrastructure-as-a-code story gets much more exposure in IT infrastructure all over the world.

Chapter 12, Scaling Out KVM with OpenStack, discusses the process of building cloud environments based on KVM. OpenStack is the standard approach to delivering just that when using KVM. In this chapter, we talk about all of the OpenStack building blocks and services, how to deploy it from scratch, and describe how to use it in production environments.

Chapter 13, Scaling Out KVM with AWS, takes us on a journey toward using public and hybrid cloud concepts by using Amazon Web Services (AWS). Like almost all the other chapters, this is a heavily hands-on chapter that you can also use to get your feet wet in terms of getting to know AWS as a concept, which will be key to deploying a hybrid-cloud infrastructure using Eucalyptus at the end of the chapter.

Chapter 14, Monitoring the KVM Virtualization Platform, introduces a very popular concept of monitoring via the Elasticsearch, Logstash, Kibana (ELK) stack. It also takes you through the whole process of setting up and integrating the ELK stack with your KVM infrastructure, all the way through to the end result – using dashboards and UIs to monitor your KVM-based environment.

Chapter 15, Performance Tuning and Optimization for KVM VMs, talks about various approaches to tuning and optimization in KVM-based environments by deconstructing all of the infrastructure design principles and putting them to (correct) use. We cover a number of advanced topics here – NUMA, KSM, CPU and memory performance, CPU pinning, the tuning of VirtIO, and block and network devices.

Chapter 16, Troubleshooting Guidelines for the KVM Platform, starts with the basics – troubleshooting KVM services and logging, and explains various troubleshooting methodologies for KVM and oVirt, Ansible and OpenStack, Eucalyptus, and AWS. These are the real-life problems that we've also encountered in our production environments while writing this book. In this chapter, we basically discuss problems related to every single chapter of this book, including problems associated with snapshots and templating.