First of all let’s try to understand all the major issues with the existing applications. After that we will see how Containers are helpful to address these issues. We will also understand how Dockers and Kubernetes are related to Containers and play a major role, especially in cloud applications.
Many of us would have encountered at least one or a combination of scenarios from the list of issues faced during our project lifecycle below
- Application behaves differently on different machine: We have an application which runs without any issue in some machines while we get some random issues when it is running on a few other machines. Basically these issues are caused by improper application environment in the target machine. For example, if our application depends on a particular version of software such as JDK version, if it is a java application, it will not function properly until the version of the machine is same as the target machine.
- Application deployment are challenging: When we deploy any application, we need to make sure that the application is installed, configuration files are updated, specific ports are binded and similarly multiple other dependencies have been taken care of. All these task makes deployment difficult and hard to get it right each time.
- Improve application performance: With the increase in Application workload, it results in and affects performance issues. It becomes a really challenging task to scale up/down each microservice of application as per demand.
- Zero downtime support: When we find some issues, we fix it and upgrade to a new version of the application. There is some downtime required when we upgrade the application. But in some cases, due to the need and requirements of a business it is not possible to have a downtime and in such cases the application should be accessible even during an upgrade.
What is a Container?
A Container is a combination of application code along with all its dependencies like runtime, system library, tools etc. in a single package so that the application runs smoothly from one computing environment to another.
We can run many Containers in the same machine and all the Containers running in the same machine share the operating system kernel. Each Container runs as an isolated process in the user space. The process of using these Containers to deploy applications is called Containerization.
How Container is different from using a Virtual Machine?
Cloud service providers use Virtual Machine (VM) to provide hardware virtualization, isolating applications from one another. Containers which provide operating system-level virtualization to isolate application has major differences as mentioned below, which makes it more efficient than a Virtual Machine
- The purpose of Virtual Machines is to virtualize a machine, whereas a Container helps to virtualize an entire operating system
- Virtual Machines are bulky and require more resources such as disk space, memory, but Containers are lightweight and need less memory and disk space
- Each Virtual Machines uses its own Operating System (OS), but we can run many Containers in a single OS
- Virtual Machines take more time to start than the Containers
Explaining Container and Docker
Docker is the most popular platform for developers and system admins to build, ship and run applications. Docker is extremely helpful in simplifying the software delivery process by making it easy to build and share images that contain your application’s entire environment. Your application typically requires specific versions for your operating system, application server, python, java, and database server. It also may require to tune the configuration files and similarly multiple other dependencies. Binding to specific ports and certain amount of memory is also one of the basic requirements for the applications. The combination of components and configuration required to run your application is what is referred to as application's entire environment.
We can certainly provide an installation script that will download and install these dependent components. But Docker simplifies this process by allowing to create an image that contains your application and infrastructure together, managed as one component. These images provided by Docker are then used to create Docker Containers to run on the Container virtualization platform. So running instance of Container image is called a Container.
Container and Kubernetes
When we run Containerized application in a single host, our application will not be able to cope up with the fault tolerance. To achieve high availability as well as scaling, our Containerized application must run on two or more host and that's where Kubernetes comes into the picture.
Kubernetes is used to automate the process of scaling, managing, updating and removing Containers in cluster nodes. In other words, it is a Container orchestration platform. Kubernetes can work with any Containerization technology. It runs Containers across multiple cluster nodes. Once Kubernetes take control over a cluster of nodes, Containers can then spun up or torn down depending upon our need at any given time. Kubernetes also support to upgrade application with zero downtime.
There are two types of nodes in Kubernetes cluster, Master Node and Worker Node. Master Node maintains the state of cluster and controls the scheduling of pods across multiple worker nodes. Pod is a group of one or more related Containers. A Worker Node will have container platform like Dockerand rkt, to manage the Containers and services to facilitate communication between application within clusters and outside.
Docker, also offers their own Container orchestration engine, named Docker Swarm. But Kubernetes is more popular and it has been accepted and used widely.
We discussed how Containers are useful for application environment in which applications can run without any environmental issue. Docker is a standalone software that helps to create Containers and makes deployment easy. Kubernetes, on the other hand, plays an important role to support scaling of application just with a simple command. Kubernetes also help to make the application available and accessible 24/7 even during an upgrade.