Kubernetes Guide
Overview
Kubernetes is a powerful open-source container orchestration platform that automates the
deployment, scaling, and management of containerized applications. It is designed to manage
applications across clusters of machines efficiently and reliably.
Key Components
Pod: Smallest deployable unit in Kubernetes that encapsulates one or more tightly
coupled containers.
Node: A worker machine (virtual or physical) that runs pods.
Cluster: A set of nodes managed by Kubernetes.
Namespace: Logical partition within a cluster to group and manage resources.
Deployment: Manages pod replicas and rolling updates.
ReplicaSet: Ensures the desired number of pod replicas are running.
Service: Exposes pods to network traffic, enabling communication between components.
Ingress: Manages external access to services, often via HTTP/HTTPS.
ConfigMap: Stores configuration data in key-value pairs.
Secret: Stores sensitive data like passwords or API tokens.
Volume: Provides persistent storage for pods.
Scheduler: Assigns pods to nodes based on resource requirements and availability.
Controller Manager: Runs controllers to manage cluster state.
etcd: A distributed key-value store for cluster state and configuration.
API Server: Frontend that handles requests to manage the Kubernetes cluster.
Core Features
Self-Healing: Automatically restarts failed containers and reschedules pods on healthy
nodes.
Scaling: Supports manual and automatic horizontal scaling of workloads.
Service Discovery & Load Balancing: Provides built-in DNS and load balancing.
Rolling Updates & Rollbacks: Updates applications seamlessly without downtime.
Declarative Configuration: Uses YAML/JSON manifests to describe desired cluster state.
Common Commands
kubectl get pods # List pods
kubectl get nodes # List cluster nodes
kubectl describe pod <name> # Describe a pod
kubectl apply -f file.yaml # Apply a configuration
kubectl delete pod <name> # Delete a pod
kubectl logs <pod-name> # View pod logs
Use Cases
Microservices deployment and management
Continuous integration and delivery (CI/CD)
Application testing and scaling
High availability and disaster recovery
Tips
Use Namespaces to separate environments (dev, test, prod).
Implement RBAC (Role-Based Access Control) for security.
Use monitoring tools like Prometheus and Grafana for observability.
Enable Horizontal Pod Autoscaling (HPA) for dynamic scaling.
Always manage secrets securely with Kubernetes Secrets or external vaults.