Kubernetes Basics
Kubernetes (K8s) is the industry-standard container orchestration platform. It automates deployment, scaling, and management of containers in production. AKS makes it easy on Azure.
Kubernetes is the manager (orchestrator) of containers. Like an air traffic controller — it knows where every plane (container) is, routes traffic to the right ones, and handles emergencies automatically.
| Problem | Kubernetes Solution |
|---|---|
| Container crashed | Automatically restarts it |
| Traffic spike | Scales from 1 to 10 pods in seconds |
| Deploy new version | Rolling update — zero downtime |
| Bad deployment | Automatic rollback |
| Load distribution | Spreads traffic across all healthy pods |
| Resource management | Packs containers onto nodes efficiently |
| Object | What it is |
|---|---|
| Pod | Smallest deployable unit — one or more containers running together |
| Deployment | Manages a set of identical pods, handles rolling updates |
| Service | Stable network endpoint (IP + DNS) for accessing pods |
| ConfigMap | Store configuration data (non-sensitive) |
| Secret | Store sensitive data (passwords, tokens) — base64 encoded |
| Namespace | Logical isolation within a cluster (dev, staging, prod) |
| Ingress | HTTP/HTTPS routing — maps URLs to services |
| Service Type | Use Case |
|---|---|
| ClusterIP (default) | Internal only — accessible within cluster |
| NodePort | Accessible on a specific port of each node — dev/testing |
| LoadBalancer | Public IP via cloud load balancer — production APIs |
Kubernetes is a container orchestration platform that automates the deployment, scaling, and management of containerised applications. It solves the challenge of running containers in production at scale: automatically restarting crashed containers, scaling based on demand, enabling zero-downtime deployments, distributing load, and managing configuration/secrets.
A Pod is the smallest deployable unit — it runs one or more containers. Pods are ephemeral (they can die and are not automatically replaced).
A Deployment manages a set of pods and ensures the desired number is always running. If a pod dies, Deployment creates a new one. It also handles rolling updates and rollbacks.
In production, you almost never create bare Pods — always use Deployments.
A Service provides a stable network endpoint (IP address + DNS name) for accessing a set of pods. Pods get random IPs that change when they restart — a Service provides a consistent address.
Service types: ClusterIP (internal only), NodePort (exposed on each node), LoadBalancer (public IP via cloud provider — creates Azure Load Balancer for AKS).
ConfigMap stores non-sensitive configuration data as key-value pairs. The data is stored in plaintext and can be viewed by anyone with cluster access.
Secret stores sensitive data (passwords, tokens, certificates). The data is base64-encoded (NOT encrypted by default). For actual security, use K8s secrets with encryption at rest enabled, or use Azure Key Vault integration.
A rolling update replaces pods one (or a few) at a time, ensuring the application remains available throughout the update. Kubernetes creates new pods with the new version and terminates old pods gradually.
With maxUnavailable: 0, it always maintains 100% capacity during the update. With maxSurge: 1, it creates one extra pod during the process.
If the new version has issues, you can roll back instantly with kubectl rollout undo deployment/name.