Exhaustive Study Guide on Virtual Machines and Containerization
Introduction to Virtualization and Resource Management * Managing computing resources is achieved by providing a software translation layer, also referred to as an abstraction layer, situated between the software and the physical hardware. * Virtualization transforms physical resources into logical or virtual resources. * This allows users and applications to use resources without the requirement of being aware of the specific physical details characterizing the underlying hardware. # Core Virtual Machine Concepts and System Components * The fundamental concept of a virtual machine (VM) is the abstraction of the hardware of a single physical computer into several distinct execution environments. * This is conceptually similar to a layered approach, but in this context, the layer creates a virtual system upon which operating systems and applications can execute. * Key Components of Virtualization: * Host: The underlying physical hardware system. * Virtual Machine Manager (VMM) or Hypervisor: The software that creates and runs virtual machines by providing an interface that is identical to the host (with the exception of paravirtualization). * Guest: A process that is provided with a virtual copy of the host. This guest is typically an operating system. * A specific example of this setup is a guest Windows OS running within a VM on top of a Linux host OS. # Organizational Motivations for Virtualization * Legacy Hardware: Organizations use virtualization so that applications originally built for legacy hardware can continue to be run. * Rapid Deployment: A new virtual machine can be deployed in just a few minutes. * Versatility: It maximizes the variety and number of applications a single computer can handle. * Consolidation: Virtualization allows for the sharing of resources among multiple applications simultaneously. * Aggregating: It facilitates combining multiple physical resources into a single virtual resource. * Dynamics: Hardware resources can be easily and dynamically allocated as needed. * Ease of Management: The technology facilitates the deployment and testing of software. * Increased Availability: In the event of a physical server failure, the VMs residing on the failed host can be quickly and automatically restarted on a different physical host. # Hypervisor Definition and Functional Responsibilities * A virtual machine is defined as a software construct that mimics the characteristics of a physical server, configured with a specific number of processors, a specific amount of RAM, storage resources, and network connectivity. * Once created, a VM can be powered on like a physical server. * The OS within a VM accesses resources presented by the hypervisor, which acts as a proxy for the guests as they request and consume physical host resources. * Primary Hypervisor Functions: * Execution management of virtual machines. * Device emulation and access control. * Execution of privileged operations on behalf of guest VMs. * Management of VM lifecycles (VM management). * Administration of the hypervisor platform and its associated software. # Categorization of Hypervisors: Type 1 and Type 2 * Type 1 Hypervisors: * These are loaded as a software layer directly onto the physical server hardware, similar to an OS installation. * They directly control the physical resources of the host. * Once installed, the server is capable of supporting guest VMs, which can be moved to new hosts without service interruption. * Examples: VMware ESXi (vSphere), Microsoft Hyper-V, Oracle VM Server, and KVM. * Type 2 Hypervisors: * These exploit the resources and functions of a host OS and run as a software module on top of that OS. * They rely on the host OS to handle all hardware interactions on their behalf. * Examples: VMware Workstation, VMware Fusion (for macOS), and Oracle VM VirtualBox. # Comparative Analysis of Hypervisor Types * Performance: Type 1 hypervisors typically perform better because they do not compete for resources with a host OS, leaving more resources available for guests. * Hosting Capacity: More VMs can be hosted on a server using a Type 1 hypervisor. * Security: Type 1 hypervisors are considered more secure. Resource requests from VMs are handled externally to the guest and cannot affect other VMs. * Flexibility: Type 2 hypervisors allow users to utilize virtualization without dedicating a whole server to that single function. * Use Cases: Type 2 is ideal for developers who need to run multiple environments while retaining the personal productivity of a standard PC OS. * Risks in Type 2: A malicious guest on a Type 2 hypervisor could potentially affect more than just itself. # Core Features and Operational Benefits * Protection: The host system is protected from VMs, and VMs are protected from one another, making it less likely for viruses to spread. * Resource Sharing: Facilitated through shared file system volumes and network communication. * State Management: VMs can be frozen, suspended, or snapped. * Snapshot: Captures a given state of a VM, allowing it to be restored later. * Cloning: Creating a copy of a VM to run both the original and the copy. * Templating: Creating an OS and application combination to be used as a master image for creating multiple identical instances. * Live Migration: Moving a running VM from one physical host to another with no interruption to user access. * Cloud Computing: The integration of these features, alongside APIs, allows programs to command cloud infrastructure (servers, storage, networking) to create new guests and virtual desktops. # Specialized Virtualization Techniques: Paravirtualization and Hardware Assistance * Paravirtualization: * A software-assisted technique using specialized APIs to link VMs with the hypervisor for optimized performance. * The guest OS (e.g., Linux or Windows) must have specialized support in its kernel. * Specific paravirtualization drivers are used to allow the OS and hypervisor to work together more efficiently, reducing hypervisor translation overhead. * Hardware-Assisted Virtualization: * AMD and Intel added processor functions (AMD-V and Intel VT-x) to enhance hypervisor performance. * Intel processors include the Virtual Machine Extensions (VMX) instruction set. * These extensions allow hypervisors to have smaller, more efficient codebases because functions are handled directly on the processor, increasing execution speed. # Virtual Appliances and Software Distribution * A virtual appliance is standalone software distributed as a virtual machine image, containing a packaged set of applications and a guest OS. * They are independent of the hypervisor or processor architecture and can run on Type 1 or Type 2 systems. * Advantages: Deploying a pre-configured appliance is significantly easier than manual system preparation and application installation. * Security Virtual Appliance (SVA) is a specific type used for monitoring and protecting other VMs. # Container Virtualization and Kernel Control Groups * Container Virtualization: * Software known as a virtualization container runs on top of the host OS kernel to provide an isolated execution environment. * Unlike VMs, containers do not emulate physical servers; instead, all applications share a common OS kernel, reducing resource overhead. * Kernel Control Groups (Cgroups) Properties: * Resource Limiting: Ensuring groups do not exceed memory limits. * Prioritization: Assigning larger shares of CPU or disk I/O to specific groups. * Accounting: Measuring resource usage for purposes like billing. * Control: Freezing, checkpointing, and restarting process groups. * Container Engine Tasks: * Maintain a lightweight runtime and toolchain for managing images and builds. * Create container processes. * Manage file system mount points. * Request resources (memory, I/O, IP addresses) from the kernel. # Operational Phases and Characteristics of Containers * Phases of Linux Containers: * Setup: Creating the environment for the container. * Configuration: Setting up the container for specific applications or commands. * Management: Managing bootstrap (start up) and shutdown. * Essential Characteristics: * No guest OS is required. * Management software simplifies the creation and maintenance procedure. * Portability Limit: Containers are typically only portable across systems with the same OS kernel (mostly Linux). * Security/Vulnerability: While having lower overhead, containerization sits between the OS and applications, potentially introducing greater security risks than hardware-level VM isolation. # Microservices and Docker Infrastructure * Microservices: This concept uses containers to implement small, deployable units, allowing for faster updates and precise scalability. * Docker: * Provides a simplified, standardized way to run containers compared to older versions like LXC. * Uses images stored in the cloud for simple and quick execution. * Principal Docker Components: * Docker Image: Read-only templates for instantiating containers. * Docker Client: Makes requests to create containers from images. * Docker Host: The platform executing the containerized applications. * Docker Engine: The runtime package that builds and runs containers. * Docker Machine: Installs the engine and configures the client. * Docker Registry: Stores the images. * Docker Hub: A public collaboration platform and repository for images. # Technical Resource Management: Processor, Memory, and I/O * Processor Strategies: * Strategy 1: Emulate a chip as software. This is highly portable but resource-intensive and inefficient. * Strategy 2: Provide segments of processing time on physical processors (pCPUs) to the virtual processors of the VM. * Memory Management: * Physical server memory (e.g., 8GB) is partitioned into smaller segments for VMs (e.g., 1GB). * The hypervisor uses translation tables to manage requests. * Techniques include Page Sharing, Ballooning, and Memory Overcommit. * I/O Management: * The guest OS makes a call to a device driver. * The device driver connects to an emulated device managed by the hypervisor. * The hypervisor then interacts with the physical NIC driver and the hardware NIC to complete the operation. # Reference * William, S. (2018). Operating Systems: Internals and Design Principles (Ninth Edition).