Kubernetes

Kubernetes

Introduction

What is Kubernetes?

It is an open-source container orchestration tool for automating the deployment, scaling, management and networking of the containerized application. It was 1st developed by Google by Go Programming Language, and now it is maintained by CNCF(Cloud Native Compute Foundation).

Kubernetes provide a platform-agnostic way to deploy and manage containerized application in a cluster of the machine. It automates many of the manual processes involved in deploying, scaling and maintaining containerized applications including the scheduling of containers onto specific machines, the deployment and rolling update of the application and the self-healing of containers and applications.

Kubernetes Architecture

When you deploy Kubernetes, you get a cluster.

A Kubernetes cluster consists of a set of worker machines, called nodes, that run containerized applications. Every cluster has at least one worker node.

The worker node(s) host the Pods that are the components of the application workload. The control plane manages the worker nodes and the Pods in the cluster. In production environments, the control plane usually runs across multiple computers and a cluster usually runs multiple nodes, providing fault tolerance and high availability.

Kubernetes Architecture - Master Components

In the Kubernetes cluster the Manager Node is responsible for maintaining the health and status of the cluster. It is done by running several components which are working together to maintain the status of the cluster and its resources.

The components of the Manager Node are:

  • Kube API Server: This component exposes the Kubernetes API, which is the primary interface for interacting with the cluster. It receives the request from the client(such as kubectl or K8s dashboard), validates them and sends them to the appropriate components for processing.

  • Kube Scheduler: This component is responsible for scheduling the Pods to run on Nodes in the cluster. It uses various algorithms and policies to decide which nodes are best fit for the particular pod, based on the factors such as resource availability and constraints.

  • Kube Controller Manager: The Controller Manager runs all the controllers on the Kubernetes Cluster. Although each controller is a separate process, to reduce complexity, all the controllers are compiled into a single process. They are as follows:

    • Node controller: Responsible for noticing and responding when nodes go down.

    • Replication controller: Watches for Job objects that represent one-off tasks, then creates Pods to run those tasks to completion.

    • Endpoints controller: Responsible for maintaining the services and their communication between internal components.

    • Service accounts and Token controllers: Create default ServiceAccounts for new namespaces, and also responsible for generating, recreating and managing tokens to join worker node to the cluster.

  • ETCD: It is a highly available distributed key-value store, which is used to store cluster wide secretes. It is only accessible by the Kubernetes API server, as it has sensitive information.

  • Container Run Time: The container runtime is the software that is responsible for running containers.

    Kubernetes supports container runtimes such as containerd, CRI-O, and any other implementation of the Kubernetes CRI (Container Runtime Interface).

Kubernetes Architecture - Node Components

  • Kubelet: Kubelet takes the specifications from the API server and ensures the application is running according to the specifications which were mentioned. Each node has its kubelet service.

  • Kube-Proxy: This proxy service runs on each node and helps in making the service available to the external host. It helps in connection forwarding to the correct resources, it is also capable of doing primitive load balancing.

Kubernetes Cluster Limitations:

  • We can have a maximum of up to 5000 Nodes in the Kubernetes Cluster(Including the Manager Node).

  • We can create up to a Maximum of 110 Pods per Worker Node.

  • We can create up to a Maximum of 1,50,000 Pods in the Kubernetes Cluster.

  • We can have a maximum of 3,00,000 containers per Kubernetes Cluster.

Understanding Kubernetes objects

Kubernetes objects are the primary building blocks used to deploy and manage applications in a Kubernetes cluster. These objects represent the state of the application and its components, such as containers, volumes, and network connections. Here are some key Kubernetes objects and their purpose:

  1. Pod: A Pod is the smallest deployable unit in Kubernetes. It represents a single instance of a running process in the cluster. A Pod can contain one or more containers, which share the same network namespace and can access the same storage volumes.

  2. Deployment: A Deployment is a higher-level object that manages a set of replica Pods. It ensures that a specified number of replica Pods are running at all times, and allows for rolling updates and rollbacks of the application.

  3. Service: A Service provides a stable IP address and DNS name that can be used to access a set of replica Pods. Services are used to enable network communication between components in the cluster and provide a way to expose the application to external traffic.

    There are several types of Services in Kubernetes, including ClusterIP, NodePort, and LoadBalancer.

    • ClusterIP is the default type, which creates a virtual IP address that is only accessible from within the cluster.

    • NodePort exposes the Service on a port on each node in the cluster.

    • LoadBalancer creates an external load balancer that routes traffic to the Service.

  4. Volume: A Volume is a directory that is accessible to one or more containers in a Pod. Volumes can be used to store data that needs to persist between container restarts or to share data between containers in a Pod.

  5. Namespace: A Namespace is a logical grouping of objects in a Kubernetes cluster. Namespaces can be used to separate applications, teams, or environments within the cluster.

  6. ConfigMap: A ConfigMap is a key-value store that can be used to store configuration data for the application. ConfigMaps can be used to pass configuration data to containers in a Pod or to configure Kubernetes objects, such as Deployments and Services.

  7. Secret: A Secret is similar to a ConfigMap, but it is used to store sensitive data, such as passwords or access tokens. Secrets are encrypted at rest and can be used to pass sensitive data to containers in a Pod.

These Kubernetes objects can be created and managed using YAML or JSON files, which define the desired state of the object. Kubernetes then takes care of creating and managing the actual state of the object in the cluster. By using these objects, developers and operators can easily manage the deployment, scaling, and configuration of applications in a Kubernetes cluster.


Thanks for reading! Hope you find this article helpful.

-K Niranjana

Did you find this article valuable?

Support Niranjana Koni by becoming a sponsor. Any amount is appreciated!