Author: Abbas Aziz Date: February 23, 2026 Project Type: Cloud Infrastructure / SRE Focus: Horizontal Pod Autoscaling (HPA) via CPU Load, Resource Quotas and Real-Time Observability Tech Stack: Kubernetes (Kind), Docker, Python (FastAPI), PostgreSQL, Prometheus, Grafana, Helm, WSL2.


1. The Scenario

The Problem: An AI-powered API service experiences unpredictable traffic spikes. During peak hours, the application pods consume excessive CPU, causing "noisy neighbor" issues on the nodes and eventually crashing the service. There is no visibility into whether the pods are over-provisioned or under-powered.

The Mission:

  1. Implement Resource Requests & Limits to ensure predictable performance.
  2. Deploy a Metrics-Server to enable cluster-level resource awareness.
  3. Configure a Horizontal Pod Autoscaler (HPA) to handle traffic surges automatically.
  4. Build an Observability Dashboard to correlate CPU stress with scaling events.

2. Infrastructure Architecture

The setup utilizes a local Kind (Kubernetes in Docker) cluster configured with a 3-node topology (1 Control Plane, 2 Workers) to simulate a distributed production environment.


3. Execution Phase

Step 1: Resource Governance (Declarative Manifests)

To prevent "OOM (Out of Memory) Kills" and CPU starvation, I defined strict boundaries for the FastAPI containers.

YAML

# Extract from fastapi-deployment.yaml resources: requests: cpu: "100m" # Guaranteed 0.1 CPU core memory: "128Mi" limits: cpu: "500m" # Burstable up to 0.5 CPU core memory: "256Mi"

Command: kubectl apply -f fastapi.yaml

image.png