Tutorials Microservices Mastery
Kubernetes Architecture: Pods, Services, and Deployments
On this page
Kubernetes (K8s) Architecture
While Docker runs containers, Kubernetes orchestrates them. It is the "Operating System" for the cloud. K8s handles scaling, self-healing (restarting crashed containers), and load balancing across a cluster of servers.
1. Core Concepts
- Pod: The smallest unit in K8s. It contains one or more containers (usually just your .NET API).
- Deployment: Defines the "State" you want. If you say "I want 3 replicas," and a server dies, K8s will automatically start a new Pod on a healthy server to maintain that number.
- Service: An internal load balancer. It provides a single stable IP/DNS for a group of Pods.
- Ingress: The "Gatekeeper" that allows external traffic from the internet into your cluster.
2. Self-Healing Magic
If your .NET process hangs or runs out of memory, K8s detects it via a Liveness Probe and physically kills/restarts the container for you. This allows for "Zero-Downtime" 2 AM recoveries.
4. Interview Mastery
Q: "Why can't we just give a Pod a static IP address?"
Architect Answer: "Pods in Kubernetes are **Ephemeral** (Temp). They are born and they die constantly during scaling or updates. Every time a Pod restarts, it gets a brand new IP address. If your API tried to talk to 'Pod-123' via IP, it would break within minutes. This is why we use **Services**. A Service has a static IP that never changes; it acts as a permanent proxy that routes traffic to whichever Pods happen to be alive at that moment."