Beyond virtualization, containers are evolving at an unprecedented pace. In this blog post, we’ll cover the basics of virtualization and take you into the world of containers. Second, explain the difference between a virtual machine and a container. Finally, let’s talk about the relationship between containers and storage.
Virtualization is the act of creating a simulated computing environment abstracted from physical computing hardware. It allows you to create multiple virtual computing instances from the hardware and software components. Mostly, these instances can be computers in the traditional sense, or they can be applications, servers, or network configurations.
A hypervisor is a type of computer software that creates and runs virtual machines. It is a lightweight software layer that sits between physical hardware and a virtualized environment. The hypervisor is the middleman who extracts resources from the raw materials of the infrastructure and directs them to various computing instances.
Virtual Machines and Containers
Virtualization enables computers to generate computers called VMs (Virtual Machines). They run on top of hypervisor software, allowing multiple OSs (Operating Systems) to share the same underlying physical hardware and operate in isolation from each other. The hypervisor virtualizes the underlying hardware, and each VM runs its own OS. Popular VM provides include VMware, Microsoft Hyper-V, Virtual Box, Xen, and more.
Containers are also instances of software-defined computing, but they run on top of a shared host OS. They package software into portable, executable units with all the dependencies needed to run anywhere, such as servers, laptops, and clouds. Popular container tools include LXC (Linux Containers), Docker, Kubernetes, and more.
Monolithic and Microservices Architecture
A monolithic architecture is the traditional model of a software program. It is built as a unified unit that is self-contained and independent from other applications. When developing with a monolithic architecture, the main advantage is the speed of development because the application is very simple based on a single code base.
Microservices architectures for application development have grown out of this container craze. Using containers, applications can be broken down into the smallest components or “services” that serve a single purpose, and these services can be developed and deployed independently of each other. Microservices don’t reduce complexity, but they make any complexity visible and easier to manage by breaking tasks into smaller processes that operate independently of each other and contribute to the whole.
For example, suppose you have an application that allows customers to purchase products. You might have a search bar, a shopping cart, a buy button, etc. Each of these “services” can live in their own container, so if the search bar fails due to high load, it doesn’t bring the whole thing down.
Virtual Machines vs. Containers
Without having to lug around all that OS code, containers are lighter weight (megabytes vs. VMs’ gigabytes) and start up faster than VMs. You can run two to three times as many applications on a single server with containers than you can with VMs. Based on that alone, one could make the case that containers are the future.
Use Cases of VMs and Containers
Both VMs and containers have benefits and drawbacks, and the ultimate decision will depend on your specific needs.
VMs are a better choice for running apps that require all of the OS’s resources and functionality when you need to run multiple applications on servers, or have a wide variety of OSs to manage. If you have an existing monolithic application that you don’t plan to or need to refactor into microservices, VMs will continue to serve your use case well.
Containers are a better choice when your biggest priority is maximizing the number of applications or services running on a minimal number of servers and when you need maximum portability. If you are developing a new app and you want to use a microservices architecture for scalability and portability, containers are the way to go. Containers shine when it comes to cloud-native application development based on a microservices architecture.
Implementing Containers in a Cluster Requires External Storage
The advantage of containers is that they can be ramped up or down quickly depending on the load. A Pod contains containers and storages. In a cluster, when the load decreases, Pods may be dropped due to load drops, process crashes, or other reasons. At this point, the state of the application must be recorded so that new instances (new Pods) get the current state when they start. Persistent storage retains data when the device is turned off. Therefore, application must store their state information outside of the Pod.
Although it was originally assumed that containers would not require persistent storage, growing implementations have demonstrated the need for some kind of continuity with containerized applications. For example, if a container hosting part of an application dies, it is easier to re-instantiate that container (local or remote) with any existing data than to recreate or copy it from another location.
You can specify the external storage as the persistent storage when you create the Pod, essentially mounting the external volume in the container. The container running in the Pod accesses the external storage transparently, like any other local storage.
CSI Connects Containers to Storage Products
The CSI (Container Storage Interface) is a standard for exposing arbitrary block and file storage systems to containerized workloads on CO (Container Orchestration) systems like Kubernetes, Mesos, Docker, or Cloud Foundry. Container orchestration is the automation of much of the operational effort required to run containerized workloads and services. This includes a wide range of things software teams need to manage a container’s lifecycle, including provisioning, deployment, scaling, networking, load balancing and more. The storage vendors provide a plugin CSI to have it work across a number of container orchestration systems.
In short, VMs help companies get the most out of their infrastructure resources by expanding the number of machines you can squeeze from a limited amount of hardware and software. Containers help companies make the most of development resources by enabling microservices and DevOps practices. In the cluster architecture, external storage is required to share the state and resources of the application. And CSI acts as an intermediary between containers and storage.