What is Kubernetes?
Kubernetes (K8s) is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications. Originally developed by Google, it provides a robust foundation for running distributed systems resiliently, handling scaling and failover for your applications.
Kubernetes Architecture
Control Plane
- • API Server: Central management entity
- • etcd: Distributed key-value store
- • Scheduler: Assigns pods to nodes
- • Controller Manager: Runs controller processes
Worker Nodes
- • kubelet: Node agent
- • kube-proxy: Network proxy
- • Container Runtime: Docker, containerd
- • Pods: Running application instances
Core Kubernetes Resources
Pod
Smallest deployable unit containing one or more containers sharing network and storage.
- • Shared IP address and port space
- • Shared storage volumes
- • Containers can communicate via localhost
apiVersion: v1 kind: Pod metadata: name: nginx-pod spec: containers: - name: nginx image: nginx:1.20 ports: - containerPort: 80
Deployment
Manages replica sets and provides declarative updates to pods with rollout and rollback capabilities.
- • Rolling updates
- • Rollback functionality
- • Scaling operations
apiVersion: apps/v1 kind: Deployment metadata: name: nginx-deployment spec: replicas: 3 selector: matchLabels: app: nginx template: metadata: labels: app: nginx spec: containers: - name: nginx image: nginx:1.20
Service
Provides stable network endpoint for a set of pods with load balancing and service discovery.
- • ClusterIP: Internal cluster access
- • NodePort: External access via node ports
- • LoadBalancer: Cloud provider integration
apiVersion: v1 kind: Service metadata: name: nginx-service spec: selector: app: nginx ports: - protocol: TCP port: 80 targetPort: 80 type: ClusterIP
Cluster Metrics Calculator
Deployment Patterns
Rolling Update
Gradually replaces old pods with new ones, ensuring zero downtime.
Blue-Green
Maintains two identical production environments, switching traffic instantly.
Canary
Releases new version to a small subset of users first.
Rolling Update Configuration
spec: strategy: type: RollingUpdate rollingUpdate: maxUnavailable: 1 maxSurge: 1 template: spec: containers: - name: app image: myapp:v2 readinessProbe: httpGet: path: /health port: 8080
Storage & Configuration Management
ConfigMaps & Secrets
Separate configuration from application code for better portability and security.
# ConfigMap apiVersion: v1 kind: ConfigMap metadata: name: app-config data: database_url: "postgres://..." # Secret apiVersion: v1 kind: Secret metadata: name: db-secret type: Opaque data: password: cGFzc3dvcmQ=
Persistent Volumes
Abstract storage resources that persist beyond pod lifecycle.
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: postgres-pvc spec: accessModes: - ReadWriteOnce resources: requests: storage: 20Gi storageClassName: fast-ssd
Real-World Kubernetes Implementations
Spotify
Runs 150+ services on Kubernetes across multiple regions.
- • Music recommendation microservices
- • Auto-scaling based on user activity
- • Multi-region disaster recovery
Airbnb
Migrated 1000+ microservices to Kubernetes for better scalability.
- • Property search and booking services
- • ML-powered pricing algorithms
- • Real-time messaging platform
Uses Kubernetes to handle traffic spikes and maintain high availability.
- • Comment and voting systems
- • Content delivery optimization
- • A/B testing infrastructure
Adopted Kubernetes for containerizing their monolithic applications.
- • Image processing pipelines
- • Search and recommendation engines
- • User analytics platform