Phase 4: Kubernetes & Fleet Scaling
๐ง Beginner Mental Model (Explain Like Iโm 5)
Think of Kubernetes (EKS) as an automated shipping port manager:
- Control Plane (
apiserver,etcd,scheduler): The port control tower that remembers where every container belongs and assigns ships to docks. - AWS VPC CNI & ALB Controller: Gives every pod a real VPC IP address so load balancers can route traffic directly to the container without extra hops.
- Karpenter: An intelligent fleet buyer that watches waiting containers and rents the exact right-sized ARM64 Spot server from AWS in 40 secondsโthen returns the server the moment it empties.
๐งญ Step-by-Step Execution Playbook for Phase 4
- Step 1 (Control Plane, CNI & CSI): Master EKS internals, IRSA, EBS (
RWO), and EFS (RWX) in Lesson 1. - Step 2 (JIT Node Autoscaling): Deploy Karpenter and Spot interruption handlers in Lesson 2.
- Step 3 (Packaging & Ingress): Structure Helm + Kustomize overlays (Lesson 3) and Shared ALB Ingress Groups (Lesson 4).
- Step 4 (Observability & Upgrades): Configure Prometheus/PromQL (Lesson 5) and CoreDNS
ndotstuning + zero-downtime EKS upgrades (Lesson 6). - Step 5 (Azure AKS & Dependent PaaS Ecosystem): Master AKS Cilium CNI Overlay, Ephemeral NVMe OS Disks, Entra Workload Identity, Key Vault CSI, Cosmos DB, Service Bus, and KEDA in Lesson 7: Azure AKS & Dependent Services.
๐ Deep-Dive Index
1. Kubernetes Architecture & Identity
- Control Plane vs Data Plane: API Server, etcd, Kubelet, Kube-Proxy.
- Networking: VPC CNI (AWS IP assignment to Pods) vs Overlay Networks.
- Authentication: IAM Roles for Service Accounts (IRSA). Tying a Kubernetes
ServiceAccountto an AWS IAM Role via OIDC.
2. Auto-Scaling (Karpenter)
- Cluster Autoscaler limitations: Slow scaling, static node groups.
- Karpenter Mechanics: Provisioners /
NodePools,NodeClaims, bypassing ASGs to talk directly to the EC2 fleet API. - Optimization: Workload consolidation, Spot instance orchestration, graceful termination handling via SQS interruption pipelines.
3. Stateful Storage Architecture
- AWS EBS CSI Driver (RWO): NVMe block storage, single-AZ affinity,
volumeBindingMode: WaitForFirstConsumeravoiding cross-AZ scheduling deadlocks, online dynamic volume expansion without pod downtime. - AWS EFS CSI Driver (RWX): Distributed Multi-AZ NFS v4.1 storage, shared multi-pod concurrent read/write, dynamic Access Point provisioning.
4. Cluster Networking & DNS Optimization
- CoreDNS
ndots:5Query Amplification: Resolving the 5-second glibc conntrack drop race condition via NodeLocal DNSCache daemonsets (169.254.20.10). - Ingress & Gateway API: AWS ALB Ingress Grouping (
group.name,target-type: ip) vs modern Gateway API (HTTPRoutedeveloper canary routing).
๐ ๏ธ Job-Essential Exercises
- Passwordless Workload Identity (IRSA):
- Create an AWS S3 bucket. Create an IAM Role with read access. Associate this role with a K8s
ServiceAccount. Deploy a Python pod using this ServiceAccount and verify it can list the S3 bucket without any AWS keys in the environment variables.
- Create an AWS S3 bucket. Create an IAM Role with read access. Associate this role with a K8s
- Karpenter Spot Scaling:
- Install Karpenter. Create a
NodePoolconfigured to use AWS Spot Instances (t3.medium, c5.large). Deploy a pod deployment with 0 replicas. Scale it to 30 replicas. Watch Karpenter instantly spin up precisely sized EC2 Spot instances.
- Install Karpenter. Create a
- Cost Consolidation:
- With the 30 replicas running across multiple nodes, scale the deployment back down to 2 replicas. Watch Karpenterโs logs as it intelligently cordons, drains, and terminates the empty nodes to eliminate cloud waste.