Kubernetes Basics in Under 5 Mins

Container Orchestration with K8s

Shashvat G
Geek Culture
4 min readMay 12, 2021

--

Photo by Garrett parker on Unsplash

Kubernetes, I am almost certain you have heard the term at some point if you are a techie. No worries, if not. In this article, we will cover the basics of Kubernetes and its high-level architecture. Kubernetes is a container orchestration system. Container orchestration is the management of individual web servers operating in containers. So, we need containers before we can orchestrate them.

Before we dive into detail, let’s understand the concept of containers briefly, as an understanding of containers is a prerequisite to Kubernetes.

So, what is a container?

A container is something that enables wrapping up all your application code and dependencies and hence making everything you need to run the application is ready to be shipped across platforms. It is important to note that Kubernetes isn’t a replacement for Docker but a supplement. If docker were a baby, K8 would be a babysitter.

Why Kubernetes?

Suppose you have a container, what next? you could deploy it. But deploying a single instance will only cater to a limited number of end-users. What if you want to scale it to millions of users? What if your application fails? What if the system hosting the instance goes down?

One way is — do it manually. But that is not pragmatic. I’ll tell you why. Managing these container instances manually is arduous and time-taking. What’s the solution? You got it right! Kubernetes can do the heavy lifting for you. It helps us deploying a microservice-based application into a Kubernetes managed cluster which makes the containers highly available and scalable.

Kubernetes is an open-source and resilient framework that automates the scaling, deployment, and operation of containers. All you need is a ready container and the rest can be taken care of by K8s.

Features

  • Automatic rollbacks/recovery with no downtime — it progressively rolls out changes to your application or its configuration, while monitoring application health to ensure it doesn’t kill all your instances at the same time. If something goes wrong, Kubernetes will roll back the change for you[1].
  • Scalability — automatic horizontal scaling based on CPU usage.
  • Config Management/Secrets — Config Maps for setting up the environment variables command line arguments, Secrets let you store and manage sensitive information, such as passwords, OAuth tokens, and ssh keys.
  • Self-Healing /Fault-Tolerance — Restarts containers that fail, replaces and reschedules containers when nodes die, kills containers that don’t respond

How does it work?

Pods — Smallest unit of K8 cluster. A container resides on a pod. The pod itself resides in a node called the worker node. The workers take instruction from the master node. Master node tells how to run the application and what is required configurations with which we can maintain the status of the application.

Kubernetes Architecture

  • Master Node
  • Worker Node
Kubernetes Cluster[1]

Master Node

  • API Service — Main component and maintains desired state. This is the only component exposed to the outside world. Users can specify the desired state (how you want to run the application) using a YAML /JSON file. The file might contain details like how many replicas to make, the number of containers, etc.
  • Scheduler — Schedules pods we need to run in the K8 cluster. Pods are volatile in nature i.e. they come to life — do their job and die. Whenever new pods come up, the scheduler maintains and ensures pods are assigned to a worker node.
  • Controller — Controls operation and what happens in the worker node. Controls volume, health check of worker node. Ex- Bring up a new node/pod.
  • Data Store — Key-value data store that stores data generated from K8 Cluster.

Worker Node

a) kubelet — Agent that runs on a worker node and makes sure all pods within the node running and talks to API service. If you are familiar with the Linux ecosystem, this is basically a daemon.

b) kube proxy — maintains network-related rules e.g. - firewalls, expose to the external networks/outside world.

c) Container runtime — This could be a service container runtime like Docker, which provides an environment that ensures containers have everything they need to run.

d) Pods — The smallest unit in the K8 Cluster which basically contains one or more containers. Ideally, you should have one container per application but this depends on your requirement.

I hope this gives you a brief idea of how it works. That’s it from me! For further info, please see this. 🎉

Takeaway

Kubernetes has revolutionized the software development 🚧 industry by making containerized applications highly available and scalable. Several conventional problems like networking can be dealt with by Kubernetes. It also supports data center outsourcing to different cloud service providers.

Kubernetes can take you to the clouds, literally! ☁️

--

--

Shashvat G
Geek Culture

Data Scientist | Analyst who aspires to continuously learn and grow in Data Science Space. Find him on LinkedIn https://www.linkedin.com/in/shashvat-gupta/