WritingScalewayScalewaypublished Nov 5, 2020seen 5d

An Introduction to Kubernetes

Open original ↗

Captured source

source ↗
published Nov 5, 2020seen 5dcaptured 3dhttp 200method plain

An Introduction to Kubernetes Build • Benedikt Rollik • 05/11/20 • 8 min read

Kubernetes (K8s) is an open-source platform for managing containerized workloads and services. Google initially developed the project and it has been made publicly available in 2014. Since then, it has a vast, rapidly growing ecosystem. The name Kubernetes derivates from the ancient Greek word meaning helmsman or pilot.

From Traditional Deployment to Containerized Deployment

To understand why Kubernetes and containerized deployment is so useful for nowadays workloads, let us go back in time and have a view on how deployment has evolved:

During the traditional deployment era , organizations ran applications directly on physical servers. There was no way to control the resources an application may consume, causing resource allocation issues. If an application consumed most of the resources of the server it ran on, this high load might have caused performance issues on other applications running on the same physical server.

A solution would be to run each application on a dedicated server, but this would cause resources to be under-used and maintenance costs to increase.

Multiple Virtual Machines (VMs) brought a beginning of solution during the virtualized deployment era . Virtualization allowed applications to be isolated between different VMs running on the same physical server, providing security layer and better resource allocation.

As this solution reduces hardware costs, each VM still requires the same administration and maintenance task as a physical machine.

The containerized deployment era brought us the concept of containers.

A container includes its running environment and all the required libraries for an application to run. Different containers with different needs can now run on the same VM or physical machine, sharing resources. Once configured, they are portable and can be easily run across different clouds and OS distributions, making software less and less dependent on hardware and reducing maintenance costs.

How Kubernetes can help you to manage Containerized Deployments

In a production environment, you may need to deal with huge amounts of containers, and you need to manage the containers running the applications to ensure there is no downtime. Managing thousands of simultaneously running containers on a cluster of machines by hand sounds like an unpleasant task.

This is what Kubernetes can do for you. It manages the lifecycle of containerized applications and services, defines how applications should run, how they are intended to interact with other applications on the outside world while providing predictability, scalability, and high availability.

Kubernetes Architecture

Kubernetes is able to manage a cluster of virtual or physical machines using a shared network to communicate between them. All Kubernetes components and workloads are configured on this cluster.

Each machine in a Kubernetes cluster has a given role within the Kubernetes ecosystem. At least one of these servers acts as the master server, in production grade workloads usually a multi-master setup is being configured, meaning that multiple servers act as master for redundancy. The master setup is the “brain” of the cluster exposing the different APIs, performing health checks on other servers, scheduling the workloads and orchestrating communication between different components. It acts as the primary point of contact with the cluster.

The other machines in the cluster are called nodes . These machines are designed to run workloads in containers, meaning each of them requires a container runtime installed on it (for example Docker or CRI-O ).

The different underlying components running in the cluster ensure that the desired state of an application matches the actual state of the cluster. In case the given state of an application changes, the master server will take the actions required to restore the desired state of the application by creating or destroying containers on the nodes, as well as adjusting network rules to route and forward traffic as requested by the master.

A user interacts with the master server either directly with the API or with additional clients by submitting a declarative plan in JSON or YAML . This plan, containing instructions about what to create and how to manage it, is interpreted by the master who decides how to deploy the application.

Kubernetes Components

Master Components

Master components provide the cluster’s control plane. These components are making global decisions about the cluster as well as detecting and responding to cluster events.

Multiple applications and processes are needed for a Kubernetes cluster to run. They are either components guaranteeing the cluster health and status, or processes allowing communication and control over the cluster.

etcd

etcd is a consistent and highly-available key-value store that is used by Kubernetes to store its configuration data, its state, and its metadata.

kube-apiserver

The kube-apiserver is a component on the master that exposes the Kubernetes API. It is the front-end for the Kubernetes control plane and the primary means for a user to interact with a cluster. The API server is the only component that communicates directly with the etcd .

kube-scheduler

The kube-scheduler is a master component watching newly created pods that have no node assigned yet and assigns them a node to run on.

It assigns the node based on individual and collective resource requirements, hardware/software/policy constraints, and more.

kube-controller-manager

The kube-controller-manager is a master component that runs controllers.

To reduce complexity, all controllers are compiled into a single binary and run in a single process.

cloud-controller-manager

The cloud-controller-manager is an add-on useful when your cluster is running on a cloud provider.

It “glues” the different capabilities, features, and APIs of different providers while maintaining relatively generic constructs internally.

You can check out how we implemented our Cloud Controller Manager on GitHub.

Node Components

Servers that perform workloads in Kubernetes (running containers) are called nodes . Nodes may be VMs or physical machines.

Node components are maintaining pods and providing the Kubernetes runtime environment. These components run on every node in the cluster.

kubelet

The kubelet is an agent running on each node and ensuring that containers are…

Excerpt shown — open the source for the full document.