Day 30 Task: Kubernetes Architecture


Kubernetes Overview

  1. Introduction to Kubernetes (K8S)

    • Kubernetes manages Docker containers in clusters.

    • Automates deployment, scaling, and healing of containers.

  2. What is Kubernetes (k8s)?

    • Open-source container management tool.

    • Automates deployment, scaling, and load balancing.

    • Supports all cloud vendors: public, hybrid, and on-premises.

  3. Benefits of Using Kubernetes

    • Automated deployment and management.

    • Scalability and high availability.

    • Cost-effectiveness and improved developer productivity.

  4. Deploying and Managing Containerized Applications With Kubernetes

    • Install Kubernetes and set up a cluster.

    • Create deployment manifest files.

    • Expose services for external access.

  5. Use Cases of Kubernetes

    • E-commerce, media, finance, healthcare.
  6. Comparison with Other Container Orchestration Platforms

    • Kubernetes offers superior scalability and networking options.
  7. The Future of Kubernetes

    • Trends include AI-powered automation, edge computing, and multi-cloud applications.
  8. Features of Kubernetes

    • Automated scheduling, self-healing, horizontal scaling, extensibility.
  9. Kubernetes Vs Docker

    • Kubernetes offers auto-scaling and auto load-balancing.
  10. Architecture of Kubernetes

    • Control Plane components: API server, scheduler, controller manager, etcd.

    • Node components: Container runtime, kubelet, kube-proxy.

Commands for Kubectl

  • View pods: kubectl get pods

  • View nodes: kubectl get nodes

  • View services: kubectl get service


Introduction

Day 30 of the 90-Day DevOps Challenge: Kubernetes Overview

🚀 Welcome to Day 30 of the 90-Day DevOps Challenge! Today, we explore Kubernetes, the leading container orchestration platform. Discover how Kubernetes automates deployment, scales applications, and enhances availability. Learn about its benefits, such as improved developer productivity and cost-effectiveness. Dive into real-world use cases across industries and gain insights into its architecture and key components. Get ready to elevate your DevOps journey with Kubernetes! 🌟


Introduction to Kubernetes (K8S)

Kubernetes is an open-source platform that manages Docker containers in the form of a cluster. Along with the automated deployment and scaling of containers, it provides healing by automatically restarting failed containers and rescheduling them when their hosts die. This capability improves the application’s availability.

What is Kubernetes (k8s)?

Kubernetes is an open-source Container Management tool that automates container deployment, container scaling, descaling, and container load balancing (also called a container orchestration tool). It is written in Golang and has a vast community because it was first developed by Google and later donated to CNCF (Cloud Native Computing Foundation). Kubernetes can group ‘n’ number of containers into one logical unit for managing and deploying them easily. It works brilliantly with all cloud vendors i.e. public, hybrid, and on-premises.

Benefits of Using Kubernetes

1. Automated deployment and management

  • If you are using Kubernetes for deploying the application then no need for manual intervention kubernetes will take care of everything like automating the deployment, scaling, and containerizing the application.

  • Kubernetes will reduce the errors that can be made by humans which makes the deployment more effective.

2. Scalability

  • You can scale the application containers depending on the incoming traffic Kubernetes offers Horizontal pod scaling the pods will be scaled automatically depending on the load.

3. High availability

  • You can achieve high availability for your application with the help of Kubernetes and also it will reduce the latency issues for the end users.

4. Cost-effectiveness

  • If there is unnecessary use of infrastructure the cost will also increase kubernetes will help you to reduce resource utilization and control the overprovisioning of infrastructure.

5. Improved developer productivity

  • Developer can concentrate more on the developing part kubernetes will reduce the efforts of deploying the application

Deploying and Managing Containerized Applications With Kubernetes

Follow the steps mentioned below to deploy the application in the form of containers.

Step 1: Install kubernetes and setup kubernetes cluster there should be minimum at least one master node and two worker nodes you can set up the kubernetes cluster in any of the cloud which are providing the kubernetes as an service.

Step 2: Know create deployment manifestfile you can create this manifests in the manifest you can specify the exact number of pods are required and what the container image and what types of resources are required after completion of writing the manifestfile apply the file using kubectl command.

Step 3: After creating the pods know you need to expose the service to the outside of the for that you need to write one more manifestfile which contains service type (e.g., LoadBalancer or ClusterIP), ports, and selectors.

Use cases of Kubernetes in real-world scenarios

Following are the some of the use cases of kuberneets in real-world scenarios

  • E-commerce: You deploy and manage the e-commerce websites by autoscaling and load balancing you can manage the millions of users and transactions.

  • Media and entertainment: You can store the static and dynamic data can deliver it to the across the world with out any latency to the end users.

  • Financial services: kubernetes is well suited for the sinical application because of the level of security it is offering.

  • Healthcare: You can store the data of patient and take care the outcomes of the health of patient.

Architecture of Kubernetes

Kubernetes follows the client-server architecture where we have the master installed on one machine and the node on separate Linux machines. It follows the master-slave model, which uses a master to manage Docker containers across multiple Kubernetes nodes. A master and its controlled nodes(worker nodes) constitute a “Kubernetes cluster”. A developer can deploy an application in the docker containers with the assistance of the Kubernetes master.

Architecture of Kubernetes

Key components of Kubernetes

1. Kubernetes- Master Node Components

Kubernetes master is responsible for managing the entire cluster, coordinates all activities inside the cluster, and communicates with the worker nodes to keep the Kubernetes and your application running. This is the entry point of all administrative tasks. When we install Kubernetes on our system we have four primary components of Kubernetes Master that will get installed. The components of the Kubernetes Master node are:

Kubernetes Architecture

Control Plane Components

It is basically a collection of various components that help us in managing the overall health of a cluster. For example, if you want to set up new pods, destroy pods, scale pods, etc. Basically, 4 services run on Control Plane:

API Server

The API server is the entry point for all the REST commands used to control the cluster. All the administrative tasks are done by the API server within the master node. If we want to create, delete, update or display in Kubernetes object it has to go through this API server.API server validates and configures the API objects such as ports, services, replication, controllers, and deployments and it is responsible for exposing APIs for every operation. We can interact with these APIs using a tool called kubectl. ‘kubectl’ is a very tiny go language binary that basically talks to the API server to perform any operations that we issue from the command line. It is a command-line interface for running commands against Kubernetes clusters

Scheduler

It is a service in the master responsible for distributing the workload. It is responsible for tracking the utilization of the working load of each worker node and then placing the workload on which resources are available and can accept the workload. The scheduler is responsible for scheduling pods across available nodes depending on the constraints you mention in the configuration file it schedules these pods accordingly. The scheduler is responsible for workload utilization and allocating the pod to the new node.

Controller Manager

Also known as controllers. It is a daemon that runs in a non terminating loop and is responsible for collecting and sending information to the API server. It regulates the Kubernetes cluster by performing lifestyle functions such as namespace creation and lifecycle event garbage collections, terminated pod garbage collection, cascading deleted garbage collection, node garbage collection, and many more. Basically, the controller watches the desired state of the cluster if the current state of the cluster does not meet the desired state then the control loop takes the corrective steps to make sure that the current state is the same as that of the desired state. The key controllers are the replication controller, endpoint controller, namespace controller, and service account, controller. So in this way controllers are responsible for the overall health of the entire cluster by ensuring that nodes are up and running all the time and correct pods are running as mentioned in the specs file.

etc

It is a distributed key-value lightweight database. In Kubernetes, it is a central database for storing the current cluster state at any point in time and is also used to store the configuration details such as subnets, config maps, etc. It is written in the Go programming language.

2. Kubernetes- Worker Node Components

Kubernetes Worker node contains all the necessary services to manage the networking between the containers, communicate with the master node, and assign resources to the containers scheduled. The components of the Kubernetes Worker node are:

Kubelet

It is a primary node agent which communicates with the master node and executes on each worker node inside the cluster. It gets the pod specifications through the API server and executes the container associated with the pods and ensures that the containers described in the pods are running and healthy. If kubelet notices any issues with the pods running on the worker nodes then it tries to restart the pod on the same node. If the issue is with the worker node itself then the Kubernetes master node detects the node failure and decides to recreate the pods on the other healthy node.

Kube-Proxy

It is the core networking component inside the Kubernetes cluster. It is responsible for maintaining the entire network configuration. Kube-Proxy maintains the distributed network across all the nodes, pods, and containers and exposes the services across the outside world. It acts as a network proxy and load balancer for a service on a single worker node and manages the network routing for TCP and UDP packets. It listens to the API server for each service endpoint creation and deletion so for each service endpoint it sets up the route so that you can reach it.

Pods

A pod is a group of containers that are deployed together on the same host. With the help of pods, we can deploy multiple dependent containers together so it acts as a wrapper around these containers so we can interact and manage these containers primarily through pods.

Commands for Kubectl

Here are some common commands for interacting with a Kubernetes cluster:

To view a list of all the pods in the cluster, you can use the following command:

kubectl get pods

To view a list of all the nodes in the cluster, you can use the following command:

kubectl get nodes

To view a list of all the services in the cluster, you can use the following command:

kubectl get services