KCNA: Kubernetes Architecture & Fundamentals

- 8 mins

Kubernetes Architecture & Fundamentals

Kubernetes (K8s) is the industry-standard container orchestrator. It automates the operational needs of running containers, including provisioning, deployment, scaling, and networking. For the KCNA, you must understand not just what it does, but how the internal “gears” turn.

Orchestration

Kubernetes provides the framework to run distributed systems resiliently.

Function Description Why It Matters
Provisioning & Deployment Automated container lifecycle management Faster, consistent deployments
Scaling Automatic scaling based on demand Cost efficiency and performance
Self-Healing Automatically fix/replace failed containers High availability
Scheduling Efficient use of compute resources Resource optimization
Service Exposure Making container services accessible Network connectivity
Security & Authorization Access control and security policies Protection and compliance
Storage Management Shared/persistent workload storage Data persistence
Extended Functionality Custom Resource Definitions (CRDs) Platform extensibility

Self-Healing Capabilities

Custom Resource Definitions (CRDs)

The Hierarchy of Components

A Kubernetes environment is organized in a specific nesting doll structure: Cluster > Node > Pod > Container

The Big Picture

🏢 Kubernetes Cluster
│
├── 🧠 Control Plane
│   ├── 🌐 kube-apiserver (API Gateway)
│   ├── 📅 kube-scheduler (Pod Placement)
│   ├── 🎛️ kube-controller-manager (State Management)
│   ├── ☁️ cloud-controller-manager (Cloud Integration - Optional)
│   ├── 🗄️ etcd (Key-Value Store)
│   ├── 🏷️ CoreDNS (DNS Resolution)
│   └── 🤖 kubelet (Node Agent)
│
└── 💼 Worker Nodes
    ├── 🤖 kubelet (Node Agent)
    ├── 🌐 kube-proxy (Network Proxy - Optional)
    ├── 🏷️ CoreDNS (DNS Resolution)
    ├── 🔧 Container Runtime
    │   ├── 📦 containerd/CRI-O (High-level Runtime)
    │   └── 🏃 runc (Low-level Runtime)
    ├── 📦 Pods
    │   ├── 🏃 Application Containers
    │   └── 🔧 Sidecar Containers (Optional)
    └── 📁 Static Pods (in /etc/kubernetes/manifests)
        ├── 🗄️ etcd (Control Plane)
        ├── 🌐 kube-apiserver (Control Plane)
        ├── 🎛️ kube-controller-manager (Control Plane)
        └── 📅 kube-scheduler (Control Plane)

The Control Plane

The control plane manages the overall state of the cluster, coordinates activities, and ensures the “Desired State” matches the “Actual State.”

kube-apiserver

Role: The core component server that exposes the Kubernetes HTTP API

It is the “front door” for all internal and external requests.

Key Functions:

In High Availability setups, nodes connect to the API server via a Load Balancer to distribute traffic across multiple replicas.

etcd

Role: Consistent and highly-available key-value store for all API server data

kube-scheduler

Role: Assigns Pods to suitable nodes based on constraints and resources:

Decision Factors:

Process:

  1. Looks for unbound Pods in etcd
  2. Evaluates valid nodes based on constraints
  3. Makes placement decision
  4. Updates etcd with the decision

kube-controller-manager (c-m)

Role: Runs controllers to implement Kubernetes API behavior

Runs control loops that monitor the cluster. For example, if a node goes down, the controller-manager notices and responds to maintain availability and desired state.

cloud-controller-manager (c-c-m)

Role: Integrates with underlying cloud providers

The c-c-m is an optional component that acts as an interface between K8s and cloud providers. It manages:

Responsibilities:

Deployment: Resides on the control plane alongside other control plane components

Control Plane Components:
├── 🌐 kube-apiserver
│   └── 🔐 Authentication & Authorization
├── 🗄️ etcd
│   ├── 📚 Cluster State Storage
│   ├── ⚖️ RAFT Consensus Protocol
│   └── 🗳️ Leader Election
├── 📅 kube-scheduler
│   ├── 🏷️ Node Selection Logic
│   ├── 💻 Resource Awareness
│   └── 🎯 Placement Decisions
├── 🎛️ kube-controller-manager
│   ├── 🔄 Control Loops
│   ├── 👀 State Monitoring
│   └── 🛠️ Remediation Actions
├── ☁️ cloud-controller-manager (Optional)
│   ├── 🖥️ Node Management
│   ├── ⚖️ Load Balancer Integration
│   └── 💾 Storage Integration
└── 🏷️ CoreDNS
    ├── 🔍 Service Discovery
    ├── 🌐 DNS Resolution
    └── 📡 Dynamic Updates

Node Components

Each worker node contains the services necessary to run application pods. Worker nodes are responsible for executing application pods and containers.

kubelet

Role: Ensures Pods are running, including their containers

Key Features:

kubelet → Container Runtime (containerd) → Low-level Runtime (runc) → Containers

kube-proxy (Optional)

Role: Maintains network rules to implement Services

Functions:

Container Runtime

Role: Software responsible for running containers

Critical Importance:

Worker Node Components:
├── 🤖 kubelet
│   ├── 📦 Pod Lifecycle Management
│   ├── 🔄 Container Runtime Interface (CRI)
│   ├── 📁 Static Pod Monitoring (/etc/kubernetes/manifests)
│   └── 🌐 API Server Communication
├── 🌐 kube-proxy (Optional)
│   ├── 🔀 Traffic Routing
│   ├── ⚖️ Load Balancing
│   └── 🌉 Service Implementation
├── 🔧 Container Runtime Stack
│   ├── 📦 High-level Runtime
│   │   ├── containerd (CNCF Graduated)
│   │   ├── CRI-O (Kubernetes-native)
│   │   └── Docker (Legacy support)
│   └── 🏃 Low-level Runtime
│       ├── runc (OCI Reference)
│       └── crun (Alternative)
├── 🏷️ CoreDNS (Pod-based)
│   ├── 🔍 Cluster DNS
│   └── 📡 Service Resolution
└── 📦 Pod Workloads
    ├── 🏃 Application Containers
    ├── 🔧 Init Containers
    ├── 🛡️ Sidecar Containers
    └── 📁 Static Pods

Container Runtimes: High Level vs. Low Level

Kubernetes uses the CRI (Container Runtime Interface) to interact with runtimes. This architecture is layered:

  1. High-Level Runtime (e.g., Containerd): Manages the entire lifecycle. It pulls images, stores them, and manages network/storage. containerd was donated to the CNCF and is a “Graduated” project.
  2. Low-Level Runtime (e.g., runc): The reference implementation of the OCI spec. It interacts directly with Linux Namespaces and cgroups to spawn the container.

containerd

runc - The Foundation

Container Runtime Interface (CRI)

Networking & Service Discovery

Container Network Interface (CNI)

CoreDNS

Role: Enhances service discovery between applications

Functions:

Load Balancer Integration

In highly available configurations:

Pod Worloads

The smallest and simplest unit in the Kubernetes object model

Key Characteristics:

Immutability Principle

Containers are intended to be stateless and immutable

Never change the code of a container that is already running

Communication Flow (kubectl)

👤 User Request
    ↓
🌐 kube-apiserver (Authentication/Authorization)
    ↓
🗄️ etcd (Store Desired State)
    ↓
📅 kube-scheduler (Pod Assignment)
    ↓
🎛️ kube-controller-manager (State Management)
    ↓
🤖 kubelet (Node Agent)
    ↓
📦 containerd (High-level Runtime)
    ↓
🏃 runc (Low-level Runtime)
    ↓
🐧 Linux Kernel (Namespaces/cgroups)
    ↓
🏃 Running Container

Lais Ziegler

Lais Ziegler

Dev in training... 👋