Introduction to Kubernetes & Architecture

Muhammad Hamza Mirza
4 min readJul 29, 2020

--

Introduction

Kubernetes is a portable, extensible, open-source platform for managing containerized workloads and services, that facilitates both declarative configuration and automation. — kubernetes.io

In other words, kubernetes provides a platform that is easier to maintain,scale up or down and manage and monitor all the aspects of the environments and applications at all times.
The key property to note is that kubernetes doesn’t create containers itself but instead lets the other container runtime applications do so such as docker.

Why do we need Kubernetes

To understand the need of kubernetes, we must know about containers. Containers allow to package up an application with all of the dependencies, into one package.

So a container or set of containers run a single application perfectly and we can manage that using docker alone, but if we had many applications running on the same container runtime comprising of thousands of containers, it would be hideous and a headache to maintain and monitor each and every container. And if we had to scale up or scale down an application, we would have to write every command manually and the same command again and again.

This is where kubernetes comes to the rescue as it provides a controlled mechanism to maintain and monitor the containers using a few commands only. To scale up or to scale down an application, we would just need to define our desire state and the kubernetes will do the work for us.

Main Features

(1) Kubernetes provides a way to expose certain ports to gain access to the containers using services.

(2) Load balancing is done using ingress to distribute traffic across the containers.

(3) The smallest unit that can be created is a pod which is made up of one or more containers.

(4) The self-heal mechanism makes kubernetes most reliable as any of the container(s) crashes, it immediately starts other container(s) to maintain the desire state defined.

(5) Every resource such as ram, CPU can be defined per container.

(6) Secrets and configurations are easily managed and injected to the correct containers.

(7) Automated rollbacks and roll outs are done which makes it easy to upgrade the version of the application and its packages.

(8) Allows to create many pods at the same time using deployments.

Architecture

When kubernetes is installed, we obtained set of components under the umbrella of a cluster.
A cluster has a single control plane and one or more worker nodes.

Kubernetes Componets — kubernetes.io

Worker Nodes

A worker node hosts all the pods that run the containerized application. It has the following three components.

(1) kubelet:
It is an agent that creates and manages the pods and removes unhealthy pods and containers and initiates new healthy pods with healthy containers as described in the pod’s specification.

(2) kube-proxy:
It is a network proxy that manages network rules on the node which allows network communication to the pod(s) from inside and outside the cluster.

(3) container-runtime:
The container runtime is the software that is responsible for running containers.

Control Plane

The control plane manages the worker nodes and makes global decisions about the cluster. It has the following five components.

(1) kube-apiserver:
It is the front-end of the control plane as it exposes the APIs to scale up or down the number of worker nodes.

(2) kube-scheduler:
It takes several scheduling factors to account to manage newly created pods which are not assigned to any worker node and assigns the pods to the any of the node, which may be the best situated.

(3) kube-controller-manager:
It manages the control processes which are divided into four parts.
(i) Node controller watches the nodes and acts when any of the node crashes.
(ii) Replication controller watches and maintains the number of pods in each node.
(iii) Endpoints controller connects the pods to their appropriate services.
(iv) Service Account & Token controller creates default service accounts and API access tokens for the new namespaces.

(4) etcd:
It is data storage which stores all the sensitive information in key value pairs.

(5) cloud-controller-manager:
It manages the control processes that are specifically related to the cloud, as it links the cluster to the cloud service provider APIs and separates the components that interact with the cloud from the cluster related components.
The manager has three parts.
(i) Node controller watches the nodes and acts when any of the node crashes.
(ii) Route controller setup the route in the cloud infrastructure.
(iii) Service controller creates, updates and remove load balancers from the cloud.

--

--

Muhammad Hamza Mirza

Software/DevOps Engineer having interest in programming, coding, algorithms & designing. I am Muhammad Hamza Mirza who loves to contribute to the community.