Introduction to K8s & Exploring Kubernetes Architecture

Nitin DhimanNitin Dhiman
6 min read

I'm stepping into one of the most critical and transformative technologies in the field: Kubernetes, often abbreviated as K8s. With the increasing adoption of containers, Kubernetes has become the standard for deploying and managing containerized applications at scale.

Introduction to K8s

Kubernetes, or K8s, is an open-source platform designed to automate the deployment, scaling, and operation of application containers. Originally developed by Google, Kubernetes was released as open-source software in 2014. It's built on more than 15 years of Google's experience running containerized workloads, combined with the best practices from the broader open-source community.

The name "Kubernetes" comes from the Greek word for "helmsman" or "pilot," which is fitting given its role in steering containerized applications through their lifecycle. The abbreviation K8s comes from replacing the eight letters "ubernete" with "8," making it easier to refer to.

Why is Kubernetes So Important?

The benefits of Kubernetes are numerous, which is why it has quickly become an indispensable tool in the DevOps world:

  1. Scalability: Kubernetes allows you to scale applications seamlessly, both horizontally (adding more instances of your application) and vertically (adding more resources to existing instances).

  2. Self-Healing: Kubernetes automatically restarts containers that fail, replaces them, kills containers that don't respond to user-defined health checks, and doesn't advertise them to clients until they are ready.

  3. Automated Rollouts and Rollbacks: Kubernetes allows you to automate the rollout of new versions of your application and roll them back if something goes wrong, all without downtime.

  4. Service Discovery and Load Balancing: Kubernetes can expose a container using the DNS name or their own IP address. If traffic to a container is high, Kubernetes can load balance and distribute the network traffic so that the deployment is stable.

  5. Infrastructure Abstraction: Kubernetes abstracts the underlying infrastructure, allowing you to deploy your applications in the same way regardless of whether you're running on-premises, in the cloud, or in a hybrid environment.

Understanding Kubernetes Architecture

To truly appreciate Kubernetes, it's essential to understand its architecture, which is composed of several key components:

  1. Control Plane: The control plane is responsible for the global view of the cluster. It ensures that the desired state of the cluster matches the actual state. The control plane includes components like the API server, etcd (a key-value store), the scheduler, and the controller manager.

  2. Nodes and Kubelets: The actual workloads run on nodes, which are worker machines in Kubernetes. Each node runs at least one container runtime (like Docker) and a process called a kubelet, which communicates with the control plane.

  3. kubectl: kubectl is the command-line interface for running commands against Kubernetes clusters. It communicates with the Kubernetes API server and can be used to deploy applications, inspect and manage cluster resources, and view logs.

  4. API Server: The API server is a key component of the control plane, exposing the Kubernetes API. It is the entry point for all administrative tasks, receiving commands from the kubectl CLI or other clients and processing them accordingly.

Tasks

  • What is Kubernetes? Write in your own words and why do we call it K8s?

    Answer: Kubernetes is an open-source platform that automates the deployment, scaling, and management of containerized applications. It groups containers that make up an application into logical units for easy management and discovery. Kubernetes is designed to be highly extensible, enabling organizations to deploy applications in a consistent manner across different environments, such as on-premises, public cloud, or hybrid cloud.

    We call it K8s because the word "Kubernetes" has eight letters between the "K" and the "s" (K-ubernete-s). To simplify the reference, the eight letters are replaced with "8," leading to the abbreviation K8s.

  • What are the benefits of using k8s?

    Answer: The benefits of using Kubernetes (k8s) include:

    1. Scalability: Kubernetes allows for easy scaling of applications, both horizontally (adding more instances) and vertically (increasing resources for existing instances).

    2. Self-Healing: Kubernetes automatically detects and replaces failed containers, ensuring that applications remain healthy and available.

    3. Automated Rollouts and Rollbacks: Kubernetes can deploy updates to applications seamlessly, and if an update fails, it can automatically rollback to a previous version.

    4. Service Discovery and Load Balancing: Kubernetes provides built-in mechanisms for service discovery and load balancing, ensuring efficient traffic management across applications.

    5. Infrastructure Abstraction: Kubernetes abstracts the underlying hardware and infrastructure, allowing for consistent deployment and management of applications across various environments (on-premises, cloud, hybrid).

    6. Efficient Resource Management: Kubernetes optimizes the use of resources by intelligently scheduling containers based on available resources and workload requirements.

  • Explain the architecture of Kubernetes.

    Answer: Kubernetes architecture is composed of several key components that work together to manage containerized applications:

    1. Control Plane:

      • API Server: The central management component that exposes the Kubernetes API, allowing users and other components to interact with the cluster.

      • etcd: A distributed key-value store that stores all the cluster data and configuration, ensuring the desired state of the cluster is maintained.

      • Scheduler: Determines which nodes (worker machines) should run newly created containers based on resource availability and other constraints.

      • Controller Manager: Manages controllers that regulate the state of various resources, such as ensuring a specific number of replicas are running.

    2. Nodes (Worker Machines):

      • Kubelet: An agent that runs on each node, communicating with the control plane and ensuring that the containers are running as instructed.

      • Container Runtime: The software responsible for running containers, such as Docker.

      • kube-proxy: Manages network rules on each node, allowing communication between containers and services.

    3. Persistent Storage: Kubernetes provides mechanisms to attach persistent storage to containers, allowing data to persist beyond the container's lifecycle.

  • What is Control Plane?

    Answer: The Control Plane is the central component of the Kubernetes architecture that manages and orchestrates the entire cluster. It includes several key components like the API Server, etcd, Scheduler, and Controller Manager, which work together to maintain the desired state of the cluster. The Control Plane's responsibilities include scheduling workloads, monitoring the state of the cluster, scaling applications, and handling updates. It essentially acts as the brain of the Kubernetes cluster, ensuring that applications run smoothly and resources are utilized efficiently.

  • Write the difference between kubectl and kubelets.

    Answer:

    • kubectl:

      • Function: kubectl is a command-line tool that allows users to interact with the Kubernetes cluster. It sends commands to the API server, which then communicates with other components of the cluster to perform actions like deploying applications, managing resources, and inspecting logs.

      • Usage: It is used by administrators and developers to execute commands that control and manage the Kubernetes cluster.

    • kubelet:

      • Function: A kubelet is an agent that runs on each node (worker machine) in a Kubernetes cluster. It ensures that the containers specified in the Pod definitions are running and are in the desired state.

      • Usage: The kubelet communicates with the Control Plane to receive instructions and reports back on the status of the containers running on the node. It directly manages container operations on the node.

Conclusion

Kubernetes is undoubtedly a cornerstone of modern DevOps practices. Understanding its architecture and the benefits it brings to containerized application management is essential for anyone looking to scale their DevOps skills. As I continue to explore Kubernetes, I’m excited to learn more about its capabilities and how it can be used to build resilient, scalable applications.

0
Subscribe to my newsletter

Read articles from Nitin Dhiman directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nitin Dhiman
Nitin Dhiman