What is Kubernetes?
☸️ What is Kubernetes?
Kubernetes (K8s) is an open-source container orchestration platform used to:
- Deploy
- Scale
- Manage containerized applications (Docker containers)
🧱 Kubernetes Architecture
🔹 Control Plane
- API Server – Entry point
- etcd – Key-value store (cluster data)
- Scheduler – Assigns pods to nodes
- Controller Manager – Maintains desired state
🔹 Worker Node
- kubelet – Communicates with control plane
- Container Runtime – Docker / containerd
- kube-proxy – Networking
📦 Core Kubernetes Components
1️⃣ Pod
- Smallest deployable unit
- Contains one or more containers
2️⃣ Deployment
- Manages Pods
- Supports scaling & rolling updates
3️⃣ Service
- Exposes Pods to network
- Types:
- ClusterIP
- NodePort
- LoadBalancer
4️⃣ Namespace
- Logical separation inside cluster
5️⃣ ConfigMap & Secret
- ConfigMap – Non-sensitive config
- Secret – Passwords, tokens
🌐 Kubernetes Networking (Interview Important)
- Every Pod gets its own IP
- Pods can communicate without NAT
- Service provides stable IP
📈 Scaling
kubectl scale deployment app --replicas=3
🔄 Rolling Update
kubectl rollout status deployment app
Rollback:
kubectl rollout undo deployment app
📄 Basic YAML Example
apiVersion: apps/v1
kind: Deployment
metadata:
name: myapp
spec:
replicas: 2
selector:
matchLabels:
app: myapp
template:
metadata:
labels:
app: myapp
spec:
containers:
- name: web
image: nginx
ports:
- containerPort: 80
Apply:
kubectl apply -f app.yaml
🔧 Common kubectl Commands
kubectl get pods
kubectl get nodes
kubectl describe pod podname
kubectl logs podname
🔐 Security Basics
- RBAC
- Network Policies
- Secrets
- Pod Security