Kubernetes: Architecture, Workloads, and Core Concepts
Kubernetes automates container deployment, scaling, and management. This post covers the cluster architecture, control plane components, and the built-in resource types used to run workloads.
Why Kubernetes
Before Kubernetes, applications ran directly on physical hardware or VMs. Infrastructure teams managed servers manually. Configuration management tools (Puppet, Chef) helped but did not solve scheduling, health checking, or self-healing. Containerisation changed the unit of deployment. Kubernetes then provided the orchestration layer: automated placement, scaling, networking, and storage management for containerised workloads.
Key problems it solves:
- Efficient bin-packing of containers onto nodes.
- Automatic restarts on failure.
- Rolling deployments and rollbacks.
- Service discovery and load balancing.
- Secrets and configuration management.
Cluster Architecture
A Kubernetes cluster consists of:
- Control plane: manages the desired state of the cluster.
- Data plane (worker nodes): runs the actual workloads.
Control Plane Components
| Component | Role |
|---|---|
etcd | Distributed key-value store; the source of truth for cluster state |
API server (kube-apiserver) | All cluster communication goes through this; validates and persists state to etcd |
Controller manager (kube-controller-manager) | Runs controllers that reconcile actual state to desired state |
Scheduler (kube-scheduler) | Assigns pods to nodes based on resource requirements and constraints |
Cloud controller manager (cloud-controller-manager) | Interfaces with cloud provider APIs (load balancers, volumes, nodes) |
Worker Node Components
| Component | Role |
|---|---|
kubelet | Agent on each node; ensures containers in pods are running and healthy |
kube-proxy | Manages network rules on nodes; routes traffic to the correct pod |
| Container runtime | Runs containers (containerd, CRI-O) |
Core Resource Types
Pod
The smallest deployable unit. A pod wraps one or more containers that share network namespace and storage volumes. In practice: one application process per pod.
Pods are ephemeral. You do not create pods directly; you create higher-level resources that manage pods.
Deployment
Manages a set of identical pods. Provides rolling updates, rollbacks, and scaling. Internally creates and manages a ReplicaSet.
ReplicaSet
Ensures a specified number of pod replicas are running. Created automatically by a Deployment.
StatefulSet
For stateful applications (databases, message queues). Provides stable network identities and persistent storage per pod.
DaemonSet
Ensures one pod runs on every (or a selected set of) nodes. Used for logging agents, monitoring daemons, network plugins.
Job and CronJob
Job: runs a pod to completion once. CronJob: runs a Job on a schedule.
Service
Provides a stable network endpoint (IP and DNS name) for a set of pods, determined by label selectors. Types:
- ClusterIP: internal only, accessible within the cluster.
- NodePort: exposes on a port on each node.
- LoadBalancer: provisions a cloud load balancer.
Other Resources
| Resource | Purpose |
|---|---|
| Namespace | Logical isolation of resources within a cluster |
| ConfigMap | Store non-sensitive configuration as key-value pairs |
| Secret | Store sensitive data (passwords, tokens, keys) |
| PersistentVolume | Cluster-level storage resource |
| Ingress | HTTP/HTTPS routing from outside the cluster to services |
| RBAC (Role, RoleBinding) | Access control within the cluster |
| CustomResourceDefinition | Extend Kubernetes with custom resource types |
Kubernetes Standard Interfaces
Kubernetes defines three standard interfaces that allow pluggable implementations:
- CRI (Container Runtime Interface): separates Kubernetes from the container runtime.
- CNI (Container Network Interface): defines how pods get network connectivity.
- CSI (Container Storage Interface): defines how storage volumes are provisioned and attached.
Key Tools
kubectl: CLI for interacting with the Kubernetes API.helm: package manager for Kubernetes (charts).k3s: lightweight Kubernetes distribution for edge and development.- Docker Desktop: includes a local Kubernetes cluster for development.