Backend & Infra // // 5 min read

Kubernetes Crash Course: Architecture

balakumar Senior Software Engineer

Kubernetes Architecture: Detailed Overview

Kubernetes is a powerful open-source platform designed to automate deploying, scaling, and operating containerized applications. Understanding its architecture is crucial for effectively managing and scaling applications. This guide provides a detailed, concise, and clear overview of Kubernetes Architecture, including its core components, their roles, and how they interact within a cluster.


1. Overview of Kubernetes Architecture

Kubernetes follows a client-server architecture and is composed of two main parts:

  • Control Plane (Master Node): Manages the Kubernetes cluster, making global decisions about the cluster (e.g., scheduling applications, maintaining desired states).
  • Worker Nodes: Run the containerized applications. Each node manages the pods that are part of the application.

Kubernetes Architecture Diagram


2. Control Plane Components

The Control Plane is responsible for managing the overall state of the cluster. It comprises several key components:

a. etcd

  • Description: A consistent and highly available key-value store used as Kubernetes' backing store for all cluster data.
  • Function:
    • Stores configuration data.
    • Maintains the state of all Kubernetes objects.
  • Characteristics:
    • Distributed and replicated to ensure reliability.
    • Supports WAL (Write-Ahead Logging) for data integrity.

b. kube-apiserver

  • Description: Acts as the front-end for the Kubernetes control plane.
  • Function:
    • Exposes the Kubernetes API.
    • Serves as the entry point for all REST commands used to control the cluster.
    • Validates and configures data for API objects.
  • Access:
    • All components communicate via the kube-apiserver.
    • Supports HTTPS for secure communication.

c. kube-scheduler

  • Description: Responsible for assigning pods to nodes.
  • Function:
    • Monitors newly created pods that have no node assigned.
    • Selects the most suitable node based on resource requirements, policies, affinity, and more.
  • Scheduling Factors:
    • Resource availability (CPU, memory).
    • Hardware/software/policy constraints.
    • Affinity and anti-affinity specifications.

d. kube-controller-manager

  • Description: Runs controller processes.
  • Function:
    • Contains various controllers like Node Controller, Replication Controller, Endpoints Controller, etc.
    • Ensures the desired state of the cluster matches the current state.
    • Manages routine tasks such as scaling, rolling updates, and handling node failures.


3. Worker Node Components

Worker Nodes run the actual applications and contain the necessary services to manage networking and communication between pods.

a. kubelet

  • Description: An agent running on each node.
  • Function:
    • Ensures containers are running in pods as per the specifications.
    • Communicates with the kube-apiserver to retrieve pod configurations.
    • Monitors pod health and reports back to the control plane.

b. kube-proxy

  • Description: Maintains network rules on nodes.
  • Function:
    • Facilitates network communication both inside and outside the cluster.
    • Implements Kubernetes Service abstraction by handling TCP/UDP stream forwarding or round-robin TCP/UDP forwarding.

c. Container Runtime

  • Description: Software responsible for running containers.
  • Function:
    • Examples include Docker, containerd, and CRI-O.
    • Manages the lifecycle of containers, including pulling images, starting, and stopping containers.

4. Additional Architectural Components

a. Pods

  • Description: The smallest and simplest Kubernetes object.
  • Function:
    • Represents a single instance of a running process in the cluster.
    • Can contain one or more tightly coupled containers.

b. Services

  • Description: An abstraction that defines a logical set of pods and a policy by which to access them.
  • Function:
    • Enables communication between different parts of the application.
    • Provides load balancing and stable IP addresses for pods.

c. Deployments

  • Description: Provides declarative updates for pods and ReplicaSets.
  • Function:
    • Manages the creation and scaling of pods.
    • Facilitates rolling updates and rollbacks.

5. Cluster Communication

  • Internal Communication:
    • Components communicate over a secure network.
    • Uses Kubernetes' internal DNS for service discovery.
  • External Communication:
    • Ingress Controllers manage external access to services.
    • Network policies define how pods communicate with each other and with external services.

6. High Availability and Scalability

  • High Availability:
    • Control Plane components like etcd and kube-apiserver can be set up in a highly available configuration.
    • Ensures the cluster remains operational despite failures.
  • Scalability:
    • Kubernetes can scale horizontally by adding more nodes.
    • Auto-scaling features adjust the number of pod replicas based on load.

7. Security in Kubernetes Architecture

  • Authentication & Authorization:
    • kube-apiserver handles authentication (e.g., certificates, tokens) and authorization (e.g., RBAC policies).
  • Network Security:
    • Network policies control traffic flow between pods.
    • Service meshes (e.g., Istio) provide advanced networking features like mutual TLS.
  • Secrets Management:
    • Sensitive information is stored securely using Kubernetes Secrets.

8. Diagrammatic Representation (Text-Based)

+----------------------------------------------------+
|                    Control Plane                   |
| +----------------+  +----------------+ +----------+ |
| |   etcd         |  | kube-apiserver | | kube-    | |
| | (Key-Value     |  |                | | scheduler| |
| |  Store)        |  |                | |          | |
| +----------------+  +----------------+ +----------+ |
|                   +---------------------------+     |
|                   | kube-controller-manager   |     |
|                   +---------------------------+     |
+----------------------------------------------------+
                |                 |              
                |                 |              
+---------------+-----------------+----------------+
|                    Worker Nodes                 |
| +------------+  +-------------+  +-----------+ |
| | kubelet    |  | kube-proxy  |  | Containers| |
| |            |  |             |  | Runtime   | |
| +------------+  +-------------+  +-----------+ |
| +------------+  +-------------+  +-----------+ |
| | Pod 1      |  | Pod 2       |  | Pod 3     | |
| |            |  |             |  |           | |
| +------------+  +-------------+  +-----------+ |
+----------------------------------------------------+

Note: This is a simplified text-based representation. For detailed diagrams, refer to the official Kubernetes documentation.


9. Summary

  • Control Plane manages the cluster's overall state, making decisions like scheduling and maintaining desired states.
  • Worker Nodes run the containerized applications, ensuring that pods are operational and communicating effectively.
  • Core Components like etcd, kube-apiserver, kube-scheduler, and kube-controller-manager work in unison to maintain cluster health and functionality.
  • Security, High Availability, and Scalability are integral to Kubernetes, ensuring robust and efficient operation of applications.

10. Additional Resources

Feel free to reach out if you need further clarification on any of these components or concepts![]()