Skip to main content
Kubernetes Essentials·Lesson 1 of 5

Kubernetes Overview

Kubernetes (often abbreviated as K8s) is an open-source platform for automating the deployment, scaling, and management of containerized applications. Originally built by Google and now maintained by the Cloud Native Computing Foundation (CNCF), it has become the industry standard for container orchestration.

Why Kubernetes?

Docker lets you run containers on a single machine. But in production, you need much more:

  • Multiple servers — one machine is a single point of failure
  • Load balancing — distribute traffic across container instances
  • Auto-scaling — add or remove instances based on demand
  • Self-healing — restart crashed containers automatically
  • Rolling updates — deploy new versions without downtime
  • Service discovery — containers need to find each other

Kubernetes solves all of these problems.

Docker vs Kubernetes

FeatureDocker (single host)Kubernetes (cluster)
Runs containersYesYes
Multi-hostNo (Swarm adds this)Yes
Auto-scalingNoYes
Self-healingRestart policies onlyFull health-based recovery
Load balancingManual (nginx/haproxy)Built-in
Rolling updatesManualBuilt-in
Service discoveryDocker DNS (single host)Cluster-wide DNS

Kubernetes Architecture

A Kubernetes cluster has two main components: the Control Plane and the Worker Nodes.

┌─────────────────────────────────────────────┐
                Control Plane                 
                                             
  ┌──────────┐  ┌────────────┐  ┌─────────┐ 
   API         Scheduler     etcd     
   Server                    (state)  
  └──────────┘  └────────────┘  └─────────┘ 
  ┌───────────────────────────┐              
   Controller Manager                      
  └───────────────────────────┘              
└─────────────────────────────────────────────┘
                                     
┌────────┴───┐  ┌───────┴────┐  ┌─────┴──────┐
  Node 1        Node 2        Node 3    
                                        
 ┌────────┐    ┌────────┐    ┌────────┐ 
  kubelet│     kubelet│     kubelet│ 
 ├────────┤    ├────────┤    ├────────┤ 
 │kube-       │kube-       │kube-    
 │proxy       │proxy       │proxy    
 ├────────┤    ├────────┤    ├────────┤ 
  Pods        Pods        Pods    
 └────────┘    └────────┘    └────────┘ 
└────────────┘  └────────────┘  └────────────┘

Control Plane components:

ComponentRole
API ServerThe frontend for the control plane. All communication goes through it.
etcdKey-value store that holds all cluster state and configuration
SchedulerDecides which node should run a new pod
Controller ManagerRuns controllers that maintain desired state (e.g., replica count)

Node components:

ComponentRole
kubeletAgent on each node that ensures containers are running
kube-proxyHandles networking and load balancing on each node
Container runtimeRuns containers (containerd, CRI-O)

Core Concepts

Pod — the smallest deployable unit. A pod wraps one or more containers that share networking and storage. Most pods run a single container.

Deployment — manages a set of identical pods. Handles scaling, rolling updates, and rollbacks.

Service — a stable network endpoint that routes traffic to pods. Pods come and go, but the service address stays the same.

Namespace — a virtual cluster for organizing resources. Common namespaces: default, kube-system, production, staging.

ConfigMap — stores non-sensitive configuration data as key-value pairs.

Secret — stores sensitive data (passwords, tokens, keys) encoded in base64.

Setting Up a Local Cluster

For learning, use minikube or kind to run Kubernetes locally:

minikube:

# Install minikube
curl -LO https://storage.googleapis.com/minikube/releases/latest/minikube-linux-amd64
sudo install minikube-linux-amd64 /usr/local/bin/minikube

# Start a cluster
minikube start

# Check status
minikube status

kind (Kubernetes in Docker):

# Install kind
go install sigs.k8s.io/kind@latest

# Create a cluster
kind create cluster --name my-cluster

# Delete the cluster
kind delete cluster --name my-cluster

kubectl — The Command Line Tool

kubectl is the primary tool for interacting with Kubernetes:

# Install kubectl
curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl"
sudo install kubectl /usr/local/bin/kubectl

# Verify connection to the cluster
kubectl cluster-info

# View nodes in the cluster
kubectl get nodes

# View all resources in the default namespace
kubectl get all

# View resources across all namespaces
kubectl get all --all-namespaces

Your First Deployment

Deploy an Nginx web server:

# Create a deployment with 3 replicas
kubectl create deployment nginx --image=nginx --replicas=3

# Check the deployment
kubectl get deployments

# Check the pods
kubectl get pods

# Expose the deployment as a service
kubectl expose deployment nginx --port=80 --type=NodePort

# Get the service URL (minikube)
minikube service nginx --url

Declarative vs Imperative

Kubernetes supports two approaches:

Imperative (commands):

kubectl create deployment nginx --image=nginx
kubectl scale deployment nginx --replicas=3

Declarative (YAML files):

apiVersion: apps/v1
kind: Deployment
metadata:
  name: nginx
spec:
  replicas: 3
  selector:
    matchLabels:
      app: nginx
  template:
    metadata:
      labels:
        app: nginx
    spec:
      containers:
        - name: nginx
          image: nginx:1.25
          ports:
            - containerPort: 80
kubectl apply -f deployment.yaml

The declarative approach is preferred because YAML files can be version-controlled, reviewed in pull requests, and reproduced consistently.

Essential kubectl Commands

# Get resources
kubectl get pods
kubectl get services
kubectl get deployments
kubectl get nodes

# Describe a resource (detailed info)
kubectl describe pod nginx-abc123

# View logs
kubectl logs nginx-abc123
kubectl logs -f nginx-abc123  # Follow

# Execute a command inside a pod
kubectl exec -it nginx-abc123 -- bash

# Delete a resource
kubectl delete deployment nginx
kubectl delete -f deployment.yaml

# Apply a configuration
kubectl apply -f deployment.yaml

# View cluster events
kubectl get events --sort-by=.metadata.creationTimestamp

Managed Kubernetes Services

In production, most teams use managed Kubernetes from cloud providers:

ServiceProvider
EKSAmazon Web Services
GKEGoogle Cloud Platform
AKSMicrosoft Azure
DigitalOcean KubernetesDigitalOcean
Linode Kubernetes EngineAkamai / Linode

Managed services handle the control plane for you — upgrades, patching, high availability — so you only manage your application workloads.

Summary

Kubernetes orchestrates containers across a cluster of machines, providing auto-scaling, self-healing, load balancing, and rolling updates. You learned the architecture (control plane + worker nodes), the core concepts (pods, deployments, services), and how to set up a local cluster. In the next lesson, you will dive into pods and deployments.