blog;

Kubernetes.

All about Kubernetes

Kubernetes.

Originally posted on Thu Jun 03 2021

Kubernetes, also known as K8s, is an open-source system for automating deployment, scaling, and management of containerized applications.
Source: https://kubernetes.io/

To understand what Kubernetes does, we first need to know more about containers.


What Are Containers?

A container (in the software world) is a standalone package of code and all of its dependencies that can be run quickly and reliably from any computing environment. The package contains everything needed to run an application.

Docker is the most well known containerization software. The package is called a Docker image, which then becomes a container when run on Docker Engine. Docker Engine can be run on most machines, which means you can have containers running almost anywhere.

A container shares the Operating System with the host machine, so it doesn't need to have those set up, which reduces the overhead in starting them up.


Containers vs Virtual Machines

Before Containers, Virtual Machines were the main way of running applications.

Containers vs Virtual Machines
Containers vs Virtual Machines
Source: https://www.docker.com/resources/what-container

Multiple containers can run on the same machine and share the OS with other containers, each running as isolated processes. Containers take up less space than VMs (container images are typically tens of MBs in size).

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 libraries - taking up tens of GBs. VMs can also be slow to boot.


Benefits of using Containers

As we have just seen, unlike VMs, containers virtualise at the OS level which makes them far more lightweight, allowing for fast boot time and lower memory consumption.

The main benefit of using a container is the consistent runtime environment for your application. The Docker image running on your laptop will be the same as one running in production, as everything the application requires is bundled into the image.

Using containers allows for easier modularity, which is useful in microservice architecture. Having each microservice in its own container allows you to make changes to each part individually without effecting the whole service.


What is Kubernetes?

Kubernetes (k8s) as we saw at the start of this post is a management system for containers. k8s will help you cluster together hosts which are running containers, and easily and efficiently manage those clusters.

Features of using k8s include:

  • Automated rollouts and roll backs
  • Service health monitoring & self healing
  • Automated scaling
  • Deploy anywhere

Kubernetes has a really great page about what it is here, so I would recommend reading that for more detailed information.

But to put it really simply, k8s looks after your containers.


How does Kubernetes Work?

When you deploy Kubernetes, you get a cluster. A Kubernetes cluster consists of a set of worker machines, called Nodes, and a Control Plane. Every cluster has at least one worker node.

The Control Plane is responsible for managing the cluster. The Control Plane coordinates all activities in your cluster, such as scheduling applications, maintaining applications' desired state, scaling applications, and rolling out new updates. The Control Plane's automatic scheduling takes into account the available resources on each Node.

Nodes contain Pods, which contain and run the containerised applications and their volumes.

Every Kubernetes Node runs at least these two:

  • Kubelet, a process responsible for communication between the Kubernetes Master and the Node; it manages the Pods and the containers running on a machine.
  • A container runtime (like Docker) responsible for pulling the container image from a registry, unpacking the container, and running the application.

Kubernetes in the Cloud

I recently did a blog post on AWS, and so thought it would be good to talk about Kubernetes integration with a cloud platform like AWS.


Amazon EKS

In AWS, Kubernetes will manage clusters of EC2 instances, and run containers on them. Instead of manually configuring Kubernetes on AWS, you can use Amazon Elastic Kubernetes Service (Amazon EKS). EKS is a fully managed service that makes it easier to use k8s on AWS.

EKS still uses the open source Kubernetes software, so any applications running in EKS will also run in any other Kubernetes environment. EKS automatically runs k8s with three masters across three Availability Zones to protect against failure and improve resilience.

AWS have something similar to EKS, ECS (Elastic Container Service), which you could use instead. One of the main benefits of using EKS though is that k8s clusters can be run and used anywhere that supports Kubernetes, whereas it would be tough to migrate from ECS to another provider.


Me

Post by

Josh Glasson

Software Developer. Creator and owner of this blog.