Introduction to Kubernetes (K8s)
Kubernetes is an open-source container orchestration platform that automates the deployment, scaling, and management of containerized applications.
Why Kubernetes?
As applications grow, managing containers manually becomes complex. Kubernetes helps by providing:
- Automated Scaling – Adds/removes containers based on demand
- Self-Healing – Restarts failed containers automatically
- Load Balancing – Distributes traffic efficiently across containers
- Service Discovery – Ensures communication between microservices
- Resource Management – Optimizes CPU & memory allocation
- Rolling Updates & Rollbacks – Ensures zero-downtime deployments
Kubernetes Architecture
Kubernetes follows a Master-Worker architecture:
Control Plane (Master Node)
Manages the cluster and makes global decisions. Key components:
- API Server – Entry point for all Kubernetes commands (kubectl, API requests)
- Scheduler – Assigns workloads (Pods) to Worker Nodes
- Controller Manager – Maintains the desired state of the cluster
- etcd – Distributed key-value store for configuration & state data
Worker Nodes
Hosts application workloads in Pods. Key components:
- Kubelet – Talks to the API Server, ensures Pods run properly
- Kube Proxy – Handles networking & load balancing
- Container Runtime – Runs the container (e.g., Docker, containerd)
Core Kubernetes Concepts
Pods
The smallest deployable unit in Kubernetes.
- Can have one or more containers inside
- Uses a shared network namespace
Deployments
- Manages replica sets to ensure the correct number of Pods are running
- Supports rolling updates & rollbacks
Services
- Exposes Pods internally (ClusterIP) or externally (LoadBalancer, NodePort)
- Ensures stable networking despite Pod restarts
ConfigMaps & Secrets
- ConfigMaps store non-sensitive configuration (like environment variables)
- Secrets store sensitive data (passwords, API keys) securely
Basic Kubernetes Commands
# List running Pods
kubectl get pods
# Check available Nodes
kubectl get nodes
# Show details of a Pod
kubectl describe pod <pod-name>
# Deploy resources from a YAML file
kubectl apply -f <file>.yaml
# Delete a specific Pod
kubectl delete pod <pod-name>Conclusion
Kubernetes simplifies container orchestration, ensuring scalability, reliability, and automation for modern applications.