Kubernetes 101
Fundamentals for Fast Bundle
Mahdi Bahreini — Backend Developer, Fast Bundle
~60 min • GCP / GKE Context
Why Kubernetes for Us?
0–5 min
Horizontal scaling
Self-healing
Config vs code
Why Kubernetes?
0–5 min
Declarative deployments
Describe desired state, K8s makes it happen
Environment consistency
Same config across dev, stage, prod
Why GCP (GKE)?
Managed control plane, easy LB
What is Kubernetes?
5–12 min
Kubernetes is a container orchestration system that manages the lifecycle of containerized applications across a cluster of machines.
Key Pattern: Hub-and-Spoke
5–12 min
All communication goes through the API Server
Everything talks to the API Server — nodes and pods never communicate directly
What is a Pod?
12–20 min
Smallest deployable unit
- One or more containers
- Shared: Network (same IP), Storage (volumes)
- Usually 1 container per pod in real-world apps
Important: Pods are ephemeral — you don't manually manage pods in production.
We don't create Pods directly — we use Deployments.
Lifecycle: Scaling
20–30 min
Scaling
- Manual: Change
replicas: 3 → replicas: 5 — K8s adds 2 pods
- Scale down: Reduce replicas → K8s terminates excess pods gracefully
- HPA (Horizontal Pod Autoscaler): Auto-scale based on CPU/memory or custom metrics
Same image, more or fewer copies — instant
Lifecycle: Rolling Updates
20–30 min
Rolling Update
- Change
image: app:v1 → image: app:v2
- K8s replaces pods gradually (one or a few at a time)
- Zero downtime — old pods serve traffic until new ones are ready
- Configurable:
maxSurge, maxUnavailable
How we deploy backend API and frontend — no maintenance window
Lifecycle: Rollbacks
20–30 min
Rollback
- New version has a bug? Revert instantly
kubectl rollout undo deployment/myapp
- K8s rolls back to the previous ReplicaSet — same zero-downtime process
- Deployment keeps revision history for rollback
Safety net for every deployment
Lifecycle: Self-Healing
20–30 min
Self-Healing
- Pod crashes or gets killed? K8s recreates it automatically
- ReplicaSet watches: "I need 3 pods, I have 2" → starts a new one
- Node fails? Pods on that node are recreated on healthy nodes
- No manual intervention — desired state is always maintained
Set it and forget it — K8s keeps your app running
The Problem: Pod Networking
30–38 min
Dynamic IPs
Ephemeral
So how do frontend and backend talk to each other?
What is a Service?
30–38 min
- Stable IP + DNS name — pods come and go, Service stays
- Load balances across matching pods
- Decouples clients from pod lifecycle
frontend → backend via service DNS (e.g. backend.default.svc.cluster.local)
Service Types
30–38 min
- ClusterIP (default): Internal only — pods/services in cluster
- NodePort: ClusterIP +
<NodeIP>:<30000-32767> — same LAN
- LoadBalancer: NodePort + cloud LB — external (GKE → GCP LB)
- Headless: No stable IP — DNS discovery for StatefulSets
What is Ingress?
30–38 min
Ingress
HTTP/HTTPS routing
- Single entry point for external traffic into the cluster
- Routes by hostname (e.g.
api.fastbundle.com) and path (e.g. /api)
- One LoadBalancer for many services — cheaper than one LB per service
- TLS/SSL termination — handle HTTPS at the edge
- GKE: Ingress creates a GCP HTTP(S) Load Balancer automatically
User → Ingress → Service → Pods
Why Not Hardcode Config?
38–45 min
ConfigMap
Secret
❌ DB_URL inside image • API keys in code
✅ Same image → dev/stage/prod with different config
ConfigMaps & Secrets
38–45 min
ConfigMap
Non-sensitive • Env vars • Files
Secret
API keys • Passwords • Base64 (not encryption)
Best practice: Same image, different config per environment
Stateless vs Stateful
45–52 min
Most services
Stateless • No local storage
Some need
Databases • Files • Caches
Q&A + Next Steps
57–60 min
Containerize
Dev namespace
What we'll do next: Containerize services • First deployment • Dev namespace
Optional: Hands-on workshop next session
Thank you
Mahdi Bahreini — Backend Developer, Fast Bundle
Questions?