FUNDAMENTALS OF KUBERNETES

Neenad Sahasrabuddhe
GDSC GHRCE
Published in
7 min readOct 19, 2020

You must have heard of the Pokémon Go game, if not then just let me tell you. Pokémon Go game developed by Niantic Labs was initially launched only in North America, Australia & New Zealand. In just a few weeks upon its worldwide release, the game reached 500+ million downloads with an average of 20+ million daily active users. Not only did Kubernetes help in horizontal and vertical scaling of containers, but it excelled in terms of every expectation.

They planned their deployment for a basic estimate and the servers were ready for a maximum of 5x times of traffic. However, the game’s popularity rose to such an extent that they had to scale up to 50x times. You would be surprised to know that Pokémon Go surpassed all engineering expectations by 50x times and has managed to keep running despite its early launch problems. This became an inspiration to many and counted as a benchmark for modern-day augmented reality games. The implementation of Kubernetes at Niantic Labs thus made this the largest Kubernetes ever deployed.

We all know how important managing applications; HTTP traffic has become in today’s fast-moving IT world.

Credits: kubernetes.io

Nowadays every big organization is moving out of its traditional approach of using virtual machines and started using Containers for deployment. So, it’s the right time for you to understand what Kubernetes is.

What is Kubernetes?

Kubernetes is a portable, extensible, open-sourced platform that orchestrates computing, networking, automate scaling, and storage infrastructure workloads from the user’s perspective. The name Kubernetes originated from Greek, meaning helmsman or pilot. Google open-sourced the Kubernetes project in 2014. Kubernetes combines over 15 years of Google’s experience running production workloads at scale with the best ideas and practices from the community. Now it is managed by Cloud Native Computing Foundation. Kubernetes is also abbreviated as K8s.

Now, let’s see some basic terminologies used with Kubernetes.

1.Containers: A container is a software package that contains everything the software needs to run. This includes system tools, libraries, and settings, etc. Containers are not installed traditionally like software programs, which makes them isolated from the other software and the operating system itself.

2.Pods: A Pod represents a group of one or more containers. containers of the same pod will share the same resources and the local network. Pods are also called an atomic unit of Kubernetes. It is used as a unit of replication.

3.Nodes: A node may be either a virtual or a physical machine, depending on the cluster. A node can have n number of pods, and the master node handles the scheduling of pods across each node in the cluster.

4.Cluster: A cluster is a group or bunch of nodes that run your containerized applications. You manage the cluster and everything it includes — in simple words, you manage your application. Clusters consist of one master node and a number of worker nodes.

Cluster Architecture

Under the hood, Kubernetes architecture revolves around the concept of a cluster, which is a set of machines called nodes. When you deploy containerized workloads with Kubernetes, it is deployed onto the cluster. Every cluster has a master node and at least one worker node. Generally, it has more than one worker node.

Now let’s take a closer look at what master node and worker node are composed of.

Master node: It is the heart (control panel) of the cluster. It controls and manages all the administrative tasks which are responsible to keep the cluster running. It comprises four main components, each having different responsibilities to look out for. They are

1. kube-apiserver: As its name suggests the kube-apiserver exposes the Kubernetes API. It serves as the frontend of the Kubernetes control panel. All communication with the cluster or outside the cluster is done via kube-apiserver. All other components communicate with it to perform their tasks and responsibilities.

2. etcd: The master node stores the state and configuration data for the entire cluster in etcd, a persistent and distributed key-value data store. Each node has access to etcd and through which, node learns how to maintain the configurations of the containers on which they’re running. It can be configured on the same server as the master node or it can be configured externally.

3. kube-scheduler: Workloads in the clusters are tracked and managed by kube-scheduler. It also tracks the capacity and resources of each node and assigns tasks based on their availability.

4. kube-controller-manager: It regulates the cluster and manages the different non-terminating control loops. It runs many controller processes and reconciles the cluster’s actual state with its desired specifications. It manages several controller functions but they all are compiled in a single binary called kube-controller-manager. Different controller functions are

· Replication controller: Responsible for maintaining the specified number of pods for every replication object in the system.

· Node controller: Responsible for monitoring the health of each node and notifies the cluster when nodes come online or become unresponsive.

· Service account and token controller: Responsible for allocation of API access tokens and default accounts to new namespaces in the cluster.

· Deployment controller: Responsible to create the deployment, scale-up, or scale down as per the demand of deployment, rollout, or rollback updates.

· Job controller: responsible for all jobs which are created or scheduled is performed smoothly without any interruption or downtime.

Worker node: These nodes are another essential component that works collectively with the master node. It contains all required services to manage networking between containers, communicate with the master node to assign certain tasks or resources to scheduled containers. It comprises three main components. They are

1. kubelet: It is the heart of the worker node. It is responsible for managing the state of the node: starting, stopping, and maintaining application containers based on instructions from the master node. It gets the pod specifications through the kube-apiserver and executes the containers associated with the pod and ensures that the containers are running and healthy.

2. kube-proxy: It acts as a load balancer and network proxy to perform service on a single worker node. It also manages network routing for TCP and UDP packets. These network rules allow communication with the pods inside or outside your cluster.

3. container runtime: To run and manage containerized applications we need container runtime on the worker node. Sometimes docker is referred to as container runtime but to be precise it is a platform that uses containers as the container runtime.

Now, you must be thinking what if master mode stops working? The solution is a high availability node. In HA node we can create n number of master nodes to prevent the failover of the application. At a time, there is only one active master node while others are in an inactive state. One of them will become active as soon as the master node stops working.

Benefits of Kubernetes

As you have seen how Kubernetes works, now let’s see what are the benefits of using it.

1. Service discovery and load balancing: Kubernetes can expose a container using the DNS name or using its own IP address. If traffic to a container is high, Kubernetes is able to load balance and distribute the network traffic so that the deployment becomes stable.

2. Storage orchestration: Kubernetes allows you to automatically mount a storage system of your choice, such as local storage, public cloud providers, virtual private cloud, and more.

3. Automated rollouts and rollbacks: Automated rollout changes that monitor the health of your application — ensuring all instances don’t fail or go down simultaneously. If something goes wrong, Kubernetes automatically rolls back the changes.

4. Automatic bin packing: You provide Kubernetes with a cluster of nodes that it can use to run containerized tasks. You can tell Kubernetes how much CPU and memory (RAM) each container needs. Kubernetes will fit containers onto your nodes to make the best use of your resources.

5. Self-healing: Kubernetes restarts containers, replaces containers, terminates containers that don’t respond to user-defined health checks, and doesn’t advertise them to clients until they are ready to serve.

6. Secret and configuration management: Kubernetes lets you store and manage sensitive information, such as passwords, OAuth tokens, and SSH and API keys. You can deploy and update secrets and application configuration without rebuilding your container images, and without exposing secrets in your stack configuration.

Reference:

You can read more about Kubernetes on https://kubernetes.io/docs/home/

https://cloud.google.com/blog/products/gcp/bringing-pokemon-go-to-life-on-google-cloud

--

--

Neenad Sahasrabuddhe
GDSC GHRCE

Developer Student Club (Core Team Member)| Data Science| Machine Learning | Cloud | He/Him