Introduction to Containerization and Kubernetes

crossML engineering
crossML Blog
Published in
5 min readApr 22, 2020
Photo by freestocks.org from Pexels

Containerization, Docker, and Kubernetes are now well-known words in the software industry.

Containers are a solution to the problem of how to reliably run the software when moving from one computing environment to another. It can range from a developer’s laptop to a test environment, from a staging environment to a product, perhaps from a physical machine in a data center to a virtual machine in a private or public cloud. In other words, containers are a form of operating system virtualization. A single container can be used to run anything from a small microservice to a software process to a large application. A container contains all the necessary executables, binary code, libraries, and configuration files. Containers do not contain operating system images when compared to server or machine virtualization systems. This makes them more lightweight and portable, and the overhead is much smaller. In large application extensions, multiple containers can be placed in one or more container clusters. Such groups are run by a container orchestrator such as Kubernetes or Docker Swarm.

After reading this you might be thinking that containers are somewhat like Virtual Machines. Well the answer to your question is YES, Containers and virtual machines have similar resource isolation and allocation benefits, but function differently because containers virtualize the operating system instead of hardware. Containers are more portable and efficient.

Containers vs Virtual Machines

CONTAINERS:

dasdasd
Source: docker.com/resources/what-container

Containers are an abstraction at the app layer that packages code and dependencies together. Multiple containers can run on the same machine and share the OS kernel with other containers, each running as isolated processes in userspace. Containers take up less space than VMs (container images are typically tens of MBs in size), can handle more applications, and require fewer VMs and Operating systems.

VIRTUAL MACHINES

Source: docker.com/resources/what-container

Virtual machines (VMs) are an abstraction of physical hardware turning one server into many servers. The hypervisor allows multiple VMs to run on a single machine. Each VM includes a full copy of an operating system, the application, necessary binaries, and libraries — taking up tens of GBs. VMs can also be slow to boot.

Benefits of Containers:

  1. Consistent Environment:

Containers give developers the ability to create predictable environments that are isolated from other applications. Containers can also include software dependencies needed by the application, such as specific versions of programming language runtimes and other software libraries.

2. Consistent Environment:

Containers are able to run virtually anywhere, greatly easing development and deployment: on Linux, Windows, and Mac operating systems; on virtual machines or bare metal; on a developer’s machine or in data centers on-premises; and of course, in the public cloud.

3. Isolation:

Containers virtualize CPU, memory, storage, and network resources at the OS-level, providing developers with a sandboxed view of the OS logically isolated from other applications.

Downsides of containers:

  • Since containers share an OS Kernel, if the OS were to encounter a vulnerability, then it would potentially affect all the containers that are rooted in the OS. VMs, on the other hand, only share the hypervisor, which has little functionality and is less prone to attacks.
  • If you are running a complex enterprise application with containers, then you will have to look after many containers, perhaps in the hundreds or even thousands. Looking after a large number of containers can be very overwhelming and increases complexity.

Now you might be guessing the title of the blog includes “Containerization and Kubernetes”, so how does Kubernetes fit in here.

Relationship with Kubernetes and Containers:

As mentioned above, handling many containers can become very complicated, so that Kubernetes and other container orchestration tools come into the picture.

Kubernetes is a powerful open-source system originally developed by Google to handle containerized applications in a clustered environment. Its mission is to provide the best possible way to manage relevant and distributed components and services across a wide variety of infrastructure. When applications (microservices) are packaged in a container with their dependencies and configuration, a tool is needed to automatically manage the containers and scale them up and down according to application access requirements. Kubernetes is the perfect tool for that.

As applications grow and are installed on multiple servers, Kubernetes can control how and where those containers work. Your application can scale horizontally while monitoring and maintaining container health.

A few key terms related to Kubernetes Formation and Kubernetes:

  • Container: An executable image that contains a single piece of software and all its dependencies. In our case, it’s a Docker container.
  • Node: A virtual or physical machine that is used as a worker for Kubernetes. Kubernetes will abstract its management away in practice. A Kubernetes cluster contains a master node that is used to manage the state of the cluster in real-time and allows user interaction.
  • Cluster: A set of nodes that run containers managed by Kubernetes. This is analogous to a Domain in Payara Server.
  • Pod: The smallest Kubernetes object. A pod runs a set of containers. Usually, pods have one container each, but in some cases, they may also include additional container services such as one to add logging capabilities, for example.
  • Deployment: An object that manages a set of replicated pods. Scaling a microservice involves adding more pods to a deployment.
  • Service: An object that describes how to access deployments or groups of pods via a common endpoint. May create things like load balancers to access the resource.
  • Label: Labels are added to Kubernetes objects (pods, deployments, services, etc.) in order to be selected together.
  • Selector: A selector references a label in order to allow the interaction with a set of objects, like multiple containers for the purposes of load balancing, for example.
  • Kubectl: The command-line utility used to interact with the Kubernetes master node.

References:

We hope this article was helpful to you. For any kind of solution related to Auto Scaling, Kubernetes or Cloud Services please contact us at hello@crossml.com

--

--