
Getting Started With Kubernetes
Nowadays, when a client asks to create a highly available distributed system, Kubernetes has become the go-to choice. This resulted in a 69 percent use growth, according to the StackRox 2020 report. This article will give you a quick overview of Kubernetes. It’ll explain which problems it solves, how it works, and what its main components are. The concept behind Kubernetes is strictly related to Microservices, so I will summarize that as well to give you a bit of context.
Microservices
Imagine this scenario: Your company has decided to develop a new social network. After a detailed analysis of the customer needs, your team starts development and, once completed, the application is published. The project is a huge success, and the application grows. Bug fixes are alternated with the building of new features, and with each release the application becomes more intractable and delicate. Your team starts feeling fatigued from outages, anxious about releasing, and generally feel like they can’t deliver new features or fixes fast enough. You might be familiar with the expression, “If it works, don’t touch it.” This fear of change is related to a lack of flexibility that we usually find in Monolithic architectures. To our rescue comes the microservices architecture. This architecture breaks down a monolithic application into small, independently running components decoupled from each other. Each component is a microservice. This approach makes the entire system more maintainable and easier to adjust to today’s rapidly changing business requirements. Each piece can be developed, deployed, updated, and scaled individually, but they all work together with other pieces as part of running a stable and business-critical application.
With great power comes great responsibility.
While microservices make your application flexible and more stable, the entire system also becomes more challenging to configure and manage as their number increases.
This is where Kubernetes comes in. Kubernetes is a software system that hides the details of resource management, monitoring, and failure handling so its developers can focus on application development. Kubernetes adds a layer of abstraction by exposing the entire hardware infrastructure as a single resource. Doing so simplifies the development, deployment, and management of both development and operations teams. The system is composed of:
- Master node
- N worker nodes
The master node
This node hosts the control plane of the Kubernetes which controls and manages the entire Kubernetes system and consist of the following components:
- Kubernetes API Server: The API that handles the communication between the control plane components and external clients.
- Scheduler: Assigns a worker node to each deployable component of your application.
- Control Manager: Daemon (a program that continuously runs as a background process) and embeds a non-terminating loop (control loop) that watches the state of the cluster through the API server and performs cluster-level functions, like replicating a component, keeping track of worker nodes, and handling node failures.
- etcd: A key-value store that holds and manages the cluster configuration.
Worker nodes
The worker nodes are machines that run the deployed applications. These nodes are composed of:
- Container runtime: Software that executes containers and manages container images on a node. For example: Docker and rkt.
- Kubelet: The process responsible for managing the containers on its node and communicating with the master node.
- Kubernetes Service Proxy (kube-proxy): Process built on iptables that routes traffic between nodes in a cluster.

How does Kubernetes work
The workflow to run an application in Kubernetes is as follows:
- A developer packages the application into one or more container images.
- Those images are pushed to an image registry. For example the Azure Container Registry or Docker Hub.
- A description of the application is sent to the Kubernetes API server via POST.
- The API server processes the description of the application.
- The Scheduler schedules the specified group of containers onto the available worker nodes based on the computational resources of each group and the unallocated resources on each node at the moment of the execution
- The kubelet process on those nodes instructs the Container Runtime (Docker, for example) to pull the required images and run the container.
Once the application is running, Kubernetes continuously ensures that the deployed state of the application always matches the provided description. If one of those instances stops working, Kubernetes will restart it automatically.

References
- Kubernetes official documentation: https://kubernetes.io/docs/home/