1 Core Concepts
Pods
The smallest deployable unit. A Pod wraps one or more containers that share networking (localhost) and storage volumes. Agent containers + sidecar tool containers run together in a single Pod.
Deployments
Declares the desired state: which container image, how many replicas, update strategy (rolling/recreate). The Deployment controller ensures reality matches the spec. Supports RollingUpdate with maxSurge and maxUnavailable.
Services
Stable network endpoint for a set of Pods. Types: ClusterIP (internal), NodePort (fixed port on nodes), LoadBalancer (cloud LB), ExternalName (DNS alias). Uses label selectors for routing.
Namespaces
Virtual clusters within a physical cluster. Isolate resources by team, environment (dev/staging/prod), or tenant. Apply ResourceQuotas and LimitRanges per namespace to prevent resource starvation.
ConfigMaps & Secrets
ConfigMaps inject non-sensitive config (env vars, config files) into Pods. Secrets store API keys, tokens, and certificates (base64-encoded, optionally encrypted at rest via KMS).
Ingress
HTTP/HTTPS routing layer that maps external hostnames and paths to internal Services. Supports TLS termination, path-based routing, and rate limiting. Common controllers: nginx-ingress, Traefik, Istio Gateway.
HPA (Autoscaling)
Horizontal Pod Autoscaler automatically scales replica count based on CPU, memory, or custom metrics (e.g., queue depth, request latency). Essential for bursty AI agent workloads.
Helm Charts
Package manager for Kubernetes. A Chart bundles all YAML manifests (Deployment, Service, Ingress, ConfigMap) into a versioned, parameterized template. values.yaml allows environment-specific overrides.
2 Architecture
3 Setup Guide
minikube (Local Development)
kind (K8s in Docker)
4 Usage Examples
Deployment + Service YAML
kubectl Essential Commands
5 Best Practices
Resource Requests & Limits
Always set requests and limits for CPU and memory. Requests guarantee scheduling; limits prevent runaway containers. Set memory limit = 2× request for bursty agent workloads. Never omit requests — it causes unpredictable scheduling.
Liveness & Readiness Probes
Configure readinessProbe (traffic routing) and livenessProbe (restart on hang). Use HTTP GET on /healthz. Set initialDelaySeconds high enough for model loading (30–120s for LLM agents).
Image Tagging
Never use :latest in production. Use immutable tags like v1.2.3-sha-abc123. Set imagePullPolicy: IfNotPresent for tagged images. Use a private registry with vulnerability scanning.
Pod Disruption Budgets
Set PodDisruptionBudget with minAvailable: 50% to ensure cluster upgrades and node drains don't take down all replicas simultaneously. Critical for maintaining agent availability during maintenance.
Network Policies
Default-deny all ingress/egress traffic per namespace, then explicitly allow required flows. Prevents a compromised agent Pod from accessing unrelated services. Use Calico or Cilium as the CNI plugin.
GitOps with ArgoCD
Store all manifests in Git. Use ArgoCD or Flux to auto-sync cluster state from the repo. Enables audit trails, rollback via git revert, and multi-cluster promotion (dev → staging → prod).
6 Scaling & Production
Cluster Autoscaler
Automatically adds or removes worker nodes based on pending Pod requests. When HPA scales Pods beyond available cluster capacity, the Cluster Autoscaler provisions new nodes from the cloud provider's node pool within 1–3 minutes.
Vertical Pod Autoscaler
VPA adjusts CPU/memory requests and limits based on actual usage. Run in "recommend" mode first to observe suggestions, then "auto" to apply. Essential for right-sizing LLM agent containers that have unpredictable memory patterns.
KEDA (Event-Driven)
Kubernetes Event-Driven Autoscaling scales based on external metrics: Kafka consumer lag, Redis queue length, Prometheus queries. Can scale to zero Pods during idle periods — critical for cost-effective agent workloads.
Multi-Cluster Federation
Run agents across multiple clusters in different regions for latency and reliability. Use Submariner for cross-cluster networking or Liqo for seamless workload offloading. Manage with ArgoCD ApplicationSets for multi-cluster GitOps.
GPU Node Pools
Create dedicated GPU node pools with taints (nvidia.com/gpu=true:NoSchedule) so only GPU workloads land there. Use GPU time-slicing or MIG (Multi-Instance GPU) to share A100s across multiple agent Pods for cost efficiency.
Cost Optimization
Use spot/preemptible instances for fault-tolerant agent workloads (70% cost savings). Combine with PodDisruptionBudgets and graceful shutdown. Monitor costs with Kubecost or OpenCost per namespace and label.
7 FAQ
minikube vs. kind vs. k3s — which should I use locally?→
How do I schedule GPU workloads?→
resources.limits: nvidia.com/gpu: 1. The scheduler assigns the Pod to a node with available GPUs. Use node selectors or taints/tolerations for dedicated GPU node pools.What is the difference between a Deployment and a StatefulSet?→
redis-0, redis-1) and persistent storage. Use StatefulSets for databases, Kafka brokers, and anything that needs stable identity.