Pages

Friday, January 19, 2024

Kubernetes in a nutshell

 Kubernetes is an open source container orchestration platform. It automates the deployment, scaling and management of the containerized applications. 

Why is it called K8s?

The number 8 refers to the 8 numbers between the first letter k and last letter s.

A kubernetes cluster is a set of machines, called nodes that are used to run containerized applications. 

There are 2 core pieces in the kubernetes cluster. 

The first is control plane. This manages the state of the cluster. In production environments, the control plane usually runs on multiple nodes that span across several data center zones. 

The second is a set of worker nodes. These nodes run the containerized application workloads.  The containerized application runs in a Pod. Pods are a smallest deployable units in Kubernetes. A pod hosts one or more containers and provide shared storage and networking for those containers. Pods are created and managed by the kubernetes control plane. They are the basic building blocks for kubernetes applications. 

Control plane consists of  core components like API server, etcd, scheduler, and the controller manager. 

API server is the primary interface between the control plane and rest of the cluster. It exposes a Restful API that allows clients to interact with the control plane and submit requests to manage the cluster. 

etcd is the distributed key value store. It stores the cluster persistent state. It is used by the API server and other component of the control plane to store and retrieve information about the cluster. 

The scheduler is responsible for scheduling the pods onto the worker nodes in the cluster. It uses information about the resources required by the pods and the available resources on the worker nodes to make placement decisions. 

The controller manager is responsible for running controllers that manage the state of the cluster. Some example includes the replication controller, which ensures that desired number of replicas of a pod are running and the deployment controller which manages the rolling updates and rollback of the deployments. 

Next is worker node, The core component of kubernetes that runs on worker node includes kubelet, container run time and kube proxy. 

The kubelet is a daemon that runs on each worker node. It is responsible for communicating with the control plane. It receives the instruction from the control plane about which pods to run on the node, and ensures that desired state of the pod is maintained. 

The container run time runs the containers on the worker nodes. It is responsible for pulling the container images from the registry, starting and stopping the containers, and managing the container resources. 

The kube proxy is a network proxy that runs on each worker nodes. It is responsible for routing the traffic to the correct pods. It also provides load balancing for the pods and ensures that traffic is distributed evenly across the pods.

When should we use Kubernetes?

Upside:

Kubernetes is scalable and highly available. It provides feature like self healing, automatic rollbacks, and horizontal scaling. It makes it easy to scale our applications up and down as needed, allowing us to respond to changes in demand quickly. Kubernetes is portable. It helps us deploy and manage applications in a consistent and reliable way regardless of the underlying infrastructure. It runs on-premise, in a public cloud or in hybrid environment. It provides a uniform way to package, deploy and manage applications. 

Downside:

First drawback is complexity. Kubernetes is complex to setup and operate. The upfront cost is high especially for organizations new to container orchestration. It requires a high level of expertise and resources to set up and manage a kubernetes environment. Second drawback is cost. Kubernetes requires a certain minimum level of resources to run in order to support all the features mentioned above. It is slightly overkill of many small organizations. 

One popular option that strikes a reasonable balance is to offload the management of the control plane to a managed kubernetes service. Managed kubernetes service are provided by the cloud providers. Some popular one are Amazon EKS, GKE on Google cloud and AKS on Azure. These services allows organizations to run the kubernetes applications without having to worry about the underlying infrastructure. They take care of the tasks that requires deep expertise like setting up and configuring the control plane, scaling the cluster, and providing ongoing maintenance and support.This is reasonable option for mid size organization to test out Kubernetes. 



No comments:

Post a Comment