Day 30 of 90 Days of DevOps Challenge: Kubernetes Architecture

Welcome to Day 30 of the 90 Days of DevOps challenge! 🎉

Today, we dive into one of the most essential tools in the world of container orchestration: Kubernetes. Understanding Kubernetes is crucial for scaling and managing containerized applications, making it a key skill in any DevOps toolkit.

Let’s explore Kubernetes architecture and break it down into digestible parts to help you understand its fundamental components.


What is Kubernetes, and Why Do We Call It K8s?

Kubernetes is an open-source platform designed to automate the deployment, scaling, and operation of containerized applications. It was originally developed by Google and is now maintained by the Cloud Native Computing Foundation (CNCF).

The name Kubernetes comes from the Greek word meaning “helmsman” or “pilot.” The abbreviation K8s is shorthand for Kubernetes, where the “8” represents the number of letters between “K” and “s” in the word.


Benefits of Using Kubernetes

Here are some of the top reasons why organizations prefer Kubernetes:

  • Scalability: Easily scale applications up or down based on traffic.

  • Automation: Kubernetes automates the deployment, scaling, and management of containerized applications.

  • Self-healing: Automatically restarts failed containers and replaces or reschedules containers when nodes die.

  • Load balancing and service discovery: Automatically balances network traffic to ensure deployments run smoothly.

  • Declarative configuration: Use YAML files to declare the desired state of your system, and Kubernetes will work to maintain it.

  • Portability: Kubernetes works with any container runtime and can be deployed in various environments (on-prem, cloud, hybrid).


Kubernetes Architecture Overview

Kubernetes has a master-slave architecture, consisting of two main components: the Control Plane and Worker Nodes.

1. Control Plane

The control plane is responsible for managing the overall state of the cluster, scheduling workloads, and handling the API requests. It consists of several key components:

  • API Server: The front end for the Kubernetes control plane. It exposes the Kubernetes API, handling REST requests and updating the state of cluster objects like pods, services, etc.

  • etcd: A key-value store used to store all cluster data persistently. It serves as the single source of truth for the cluster.

  • Scheduler: Responsible for placing pods on the available nodes. It watches for new pod creation and assigns them to appropriate nodes based on resource availability.

  • Controller Manager: Manages the controllers, ensuring that the actual state of the cluster matches the desired state defined in the configuration.

2. Worker Nodes

The worker nodes handle the execution of the actual workloads (containers). Each worker node contains the following components:

  • Kubelet: The agent that runs on each node in the cluster. It communicates with the API server and manages the containers on its node.

  • Container Runtime: The software responsible for running containers (e.g., Docker, containerd).

  • Kube-proxy: Responsible for maintaining network rules on nodes. It enables communication between different services in the cluster.


What is the Control Plane?

The Control Plane is the brain of the Kubernetes cluster. It manages the entire lifecycle of applications running in the cluster, making decisions about scheduling, monitoring the health of the cluster, and ensuring that the desired state of the system is maintained. The control plane consists of the API server, etcd, the scheduler, and the controller manager, all working together to provide high-level orchestration.


Difference Between kubectl and kubelet

  • kubectl:

    • It's a command-line interface (CLI) tool used to interact with the Kubernetes API server. Using kubectl, administrators can issue commands to create, manage, and inspect Kubernetes resources like pods, services, and deployments.

    • Example: kubectl get pods retrieves information about all running pods in the cluster.

  • kubelet:

    • It’s an agent that runs on every worker node and ensures that containers are running as expected. The kubelet communicates with the API server to get the instructions on what workloads (pods) to run on its node.

    • It checks the health of containers and reports back to the control plane if something is wrong.


The Role of the API Server

The API Server is the front end of the Kubernetes control plane. It is the component that all the other parts of Kubernetes interact with, whether it’s users (via kubectl), controllers, or the scheduler. It acts as the communication hub for all internal components and external tools, processing RESTful requests and updating the cluster's state in etcd.

Key Roles of the API Server:

  • Handles REST requests: Any interaction with Kubernetes, whether it's creating resources or inspecting cluster states, goes through the API server.

  • Authentication and authorization: It authenticates users and services making requests and ensures they have the necessary permissions.

  • Validates and configures data: Ensures the configuration sent to Kubernetes is valid before updating etcd.


Conclusion

Today, we covered the architecture of Kubernetes and learned about its critical components like the control plane, worker nodes, kubectl, and kubelet. Understanding Kubernetes is key to deploying and managing containerized applications at scale, which makes it an indispensable part of DevOps.

Continue to refine your knowledge, and don’t forget to share your insights and progress on LinkedIn using the hashtag #90DaysOfDevOps!