Skip to content
About Me
----

GenAIOps & LLM Inference on Kubernetes: vLLM, PagedAttention & EKS GPU Scaling

Architect Key Takeaways

Production guide to operating Large Language Models on Kubernetes, featuring vLLM PagedAttention mechanics, continuous batching, Karpenter GPU node provisioning, and KEDA token queue autoscaling.

GenAIOps & LLM Inference on Kubernetes: vLLM, PagedAttention & EKS GPU Scaling

Section titled โ€œGenAIOps & LLM Inference on Kubernetes: vLLM, PagedAttention & EKS GPU Scalingโ€

Serving traditional machine learning models (like fraud classifiers or recommendation trees) requires sub-millisecond CPU/GPU compute for small tabular tensors. In contrast, serving Large Language Models (LLMs) like Llama 3, Mistral, and DeepSeek introduces unique infrastructure bottlenecks:

  • Multi-gigabyte model weights requiring massive High Bandwidth Memory (HBM/VRAM).
  • KV-Cache Memory Fragmentation: Autoregressive token generation consumes dynamic memory per concurrent user, quickly leading to Out-Of-Memory (OOM) GPU crashes.
  • High operational costs ($10,000s/month) for idle GPU clusters.

GenAIOps (Generative AI Operations) is the specialized engineering discipline for deploying, optimizing, securing, and scaling LLM infrastructure reliably in cloud-native environments.

GenAIOps and AIOps Architecture


In standard HuggingFace Transformers pipelines, memory for the Key-Value (KV) Cache must be pre-allocated contiguously for the maximum possible sequence length (e.g., 8,192 tokens). Because most user prompts are short, 60% to 80% of expensive GPU VRAM is wasted in fragmentation.

vLLM (an open-source project from UC Berkeley) introduced PagedAttention, inspired by classic operating system virtual memory paging:

โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
โ”‚ GPU High Bandwidth Memory (VRAM) โ”‚
โ”‚ โ”‚
โ”‚ Traditional Serving: Heavy Memory Fragmentation โ”‚
โ”‚ [Prompt 1: 50 toks] [ WASTED RESERVED VRAM: 2000 toks ]โ”‚
โ”‚ โ”‚
โ”‚ vLLM PagedAttention: Non-Contiguous Physical Pages โ”‚
โ”‚ โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ” โ”‚
โ”‚ โ”‚ Page 1 โ”‚ โ”‚ Page 2 โ”‚ โ”‚ Page 3 โ”‚ โ”‚ Page 4 โ”‚ โ”‚
โ”‚ โ”‚ (16 toks)โ”‚ โ”‚ (16 toks)โ”‚ โ”‚ (16 toks)โ”‚ โ”‚ (16 toks)โ”‚ โ”‚
โ”‚ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜ โ”‚
โ”‚ * Physical pages allocated on-demand as tokens stream *โ”‚
โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
  1. Zero Memory Waste: Dynamic page allocation brings VRAM waste down to under 4%.
  2. Continuous Iteration-Level Batching: Instead of waiting for an entire batch to finish generating all sentences, new incoming requests join the batch at the token level immediately.
  3. 4x - 10x Serving Throughput: Allows 10x more concurrent users on a single NVIDIA A10G or H100 GPU compared to basic HuggingFace serving.

Deploying an OpenAI-compatible vLLM inference server on Kubernetes:

apiVersion: apps/v1
kind: Deployment
metadata:
name: vllm-llama3-service
namespace: genai
labels:
app.kubernetes.io/name: vllm-llama3
spec:
replicas: 2
selector:
matchLabels:
app: vllm-llama3
template:
metadata:
labels:
app: vllm-llama3
annotations:
prometheus.io/scrape: "true"
prometheus.io/port: "8000"
prometheus.io/path: "/metrics"
spec:
# Toleration for Karpenter Spot GPU instances
tolerations:
- key: "nvidia.com/gpu"
operator: "Exists"
effect: "NoSchedule"
nodeSelector:
node.kubernetes.io/instance-type: "g5.4xlarge" # 1x NVIDIA A10G (24GB VRAM)
containers:
- name: vllm-server
image: vllm/vllm-openai:v0.4.0
args: [
"--model", "meta-llama/Meta-Llama-3-8B-Instruct",
"--tensor-parallel-size", "1",
"--gpu-memory-utilization", "0.90",
"--max-model-len", "8192",
"--port", "8000"
]
env:
- name: HUGGING_FACE_HUB_TOKEN
valueFrom:
secretKeyRef:
name: hf-token-secret
key: token
ports:
- containerPort: 8000
name: http
resources:
requests:
cpu: "8"
memory: "32Gi"
nvidia.com/gpu: "1"
limits:
cpu: "14"
memory: "48Gi"
nvidia.com/gpu: "1"
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 60
periodSeconds: 10

Standard CPU/Memory metrics are useless for autoscaling LLM deployments because a GPU running vLLM will always report near 100% memory allocation (due to the pre-allocated PagedAttention KV cache).

Instead, KEDA (Kubernetes Event-Driven Autoscaling) scales vLLM pods based on Prometheus metrics tracking the number of waiting requests / pending tokens:

apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: vllm-gpu-scaler
namespace: genai
spec:
scaleTargetRef:
name: vllm-llama3-service
minReplicaCount: 1
maxReplicaCount: 8
cooldownPeriod: 300
triggers:
- type: prometheus
metadata:
serverAddress: http://prometheus-k8s.monitoring.svc.cluster.local:9090
metricName: vllm_num_requests_waiting
query: sum(vllm:num_requests_waiting{namespace="genai"})
threshold: "5" # Add an extra GPU node for every 5 queued requests

  1. Pre-Cache Model Weights via CSI / Ephemeral Volumes: Downloading a 30GB model checkpoint from Hugging Face on every pod restart creates massive container launch delays (10+ minutes). Pre-load weights into an Amazon EFS share or an S3-backed AWS Mountpoint CSI Driver for instant container boot times.
  2. Pin Model Quantization for FinOps: Use AWQ (Activation-aware Weight Quantization) or GPTQ (4-bit) to fit an 8B model into 6GB of VRAM or a 70B model into 40GB of VRAM, running on low-cost single-GPU instances instead of expensive multi-GPU clusters.
  3. Expose Standard OpenAI Endpoints: By running --port 8000 with vllm.entrypoints.openai.api_server, your internal engineering teams can consume the self-hosted LLM using standard OpenAI client libraries (openai.ChatCompletion.create) by simply pointing base_url="http://vllm-llama3.genai.svc:8000/v1".