From 5e79d18bce7e9cc691352eadfce550e29b1762b3 Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Wed, 18 Nov 2026 21:24:59 +0100 Subject: [PATCH 1/5] Add Kubernetes rightsizing test workloads --- test-data/README.md | 2 + test-data/rightsizing/README.md | 57 +++++++++ test-data/rightsizing/cpu/kustomization.yaml | 9 ++ test-data/rightsizing/cpu/namespace.yaml | 4 + test-data/rightsizing/cpu/workloads.yaml | 120 +++++++++++++++++++ test-data/rightsizing/gpu/inference.yaml | 66 ++++++++++ test-data/rightsizing/gpu/kustomization.yaml | 8 ++ 7 files changed, 266 insertions(+) create mode 100644 test-data/rightsizing/README.md create mode 100644 test-data/rightsizing/cpu/kustomization.yaml create mode 100644 test-data/rightsizing/cpu/namespace.yaml create mode 100644 test-data/rightsizing/cpu/workloads.yaml create mode 100644 test-data/rightsizing/gpu/inference.yaml create mode 100644 test-data/rightsizing/gpu/kustomization.yaml diff --git a/test-data/README.md b/test-data/README.md index 8902519..c4d4e07 100644 --- a/test-data/README.md +++ b/test-data/README.md @@ -1,5 +1,7 @@ # Testing resources for Kedify & KEDA +[Rightsizing test workloads](rightsizing/) exercise CPU, memory, and optional GPU recommendations. + ## Install all test resources Copy and run this block to install all test resources: diff --git a/test-data/rightsizing/README.md b/test-data/rightsizing/README.md new file mode 100644 index 0000000..713fe51 --- /dev/null +++ b/test-data/rightsizing/README.md @@ -0,0 +1,57 @@ +# Kubernetes rightsizing test workloads + +Use these synthetic workloads to compare sizing advice in Kedify Insights, +PerfectScale, or other Kubernetes tooling. The manifests use standard Kubernetes +APIs and do not install a recommender or require a public endpoint. + +```bash +kubectl apply -k test-data/rightsizing/cpu +kubectl -n rightsizing get pods +kubectl -n rightsizing top pods --containers +``` + +Allow about 4 vCPUs and 8 GiB of allocatable capacity for the lab and your +observability agents. The CPU workloads reuse the +[load-generator sample](../../samples/load-generator) at a pinned image digest. +CPU and memory settings are targets, so use measured usage when comparing tools. + +| Workload | Signal to look for | +| --- | --- | +| `overprovisioned` | Steady CPU and memory usage well below requests. | +| `cpu-throttled` | Five-minute bursts capped at 350m despite a 900m target. Compare throttling and the CPU limit recommendation with `bursty-unthrottled`. | +| `bursty-unthrottled` | The same high-load profile with room to reach its CPU target. Look for recommendations that preserve headroom for bursts. | +| `mixed-containers` | Application memory usage exceeds its request while the idle nginx sidecar has oversized requests. Look for distinct per-container recommendations. | + +## Optional NVIDIA inference + +This fixture reuses the [vLLM sample's model](../../samples/vllm-autoscaling). +It needs a node advertising `nvidia.com/gpu`, plus DCGM workload metrics for +GPU utilization and framebuffer memory. It defaults to zero replicas so CPU +labs can keep the configuration without reserving a GPU. + +```bash +kubectl apply -k test-data/rightsizing/gpu +kubectl -n rightsizing-gpu scale deployment/vllm --replicas=1 +kubectl -n rightsizing-gpu rollout status deployment/vllm --timeout=15m +kubectl -n rightsizing-gpu port-forward svc/vllm 8000:8000 +``` + +In a second terminal, send a completion request. + +```bash +curl -fsS http://localhost:8000/v1/completions \ + -H 'Content-Type: application/json' \ + -d '{"model":"opt125m","prompt":"The capital of France is","max_tokens":32}' +``` + +Compare compute activity with framebuffer allocation while idle and under load. +vLLM preallocates KV cache, so GPU memory use can stay high while compute is idle. +When done, scale the Deployment back to zero. If you added a dedicated GPU node +pool, scale that pool back down separately to stop billing for its nodes. + +## Comparing results + +Record the tool's observation window, sample coverage, current and suggested +requests and limits, reason, estimated savings, and any prerequisites for +applying the advice. Check usage and restart counts alongside recommendations. +Use the same cluster state and observation window when comparing two tools. diff --git a/test-data/rightsizing/cpu/kustomization.yaml b/test-data/rightsizing/cpu/kustomization.yaml new file mode 100644 index 0000000..3fa355d --- /dev/null +++ b/test-data/rightsizing/cpu/kustomization.yaml @@ -0,0 +1,9 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: rightsizing +resources: + - namespace.yaml + - workloads.yaml +images: + - name: ghcr.io/kedify/sample-load-generator + digest: sha256:b36671f195698e6c7405b04c92833376d4303047d2dd2db56b7abdebfabdd95d diff --git a/test-data/rightsizing/cpu/namespace.yaml b/test-data/rightsizing/cpu/namespace.yaml new file mode 100644 index 0000000..663ab96 --- /dev/null +++ b/test-data/rightsizing/cpu/namespace.yaml @@ -0,0 +1,4 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: rightsizing diff --git a/test-data/rightsizing/cpu/workloads.yaml b/test-data/rightsizing/cpu/workloads.yaml new file mode 100644 index 0000000..e476293 --- /dev/null +++ b/test-data/rightsizing/cpu/workloads.yaml @@ -0,0 +1,120 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: overprovisioned +spec: + replicas: 1 + selector: + matchLabels: + app: overprovisioned + template: + metadata: + labels: + app: overprovisioned + spec: + containers: + - name: load-generator + image: ghcr.io/kedify/sample-load-generator + env: + - name: BASELINE_CPU_MILLICORES + value: "40" + - name: BASELINE_MEMORY_MIB + value: "64" + resources: + requests: {cpu: 600m, memory: 640Mi} + limits: {cpu: "1", memory: 1Gi} + readinessProbe: + httpGet: {path: /healthz, port: 8080} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: cpu-throttled +spec: + replicas: 1 + selector: + matchLabels: + app: cpu-throttled + template: + metadata: + labels: + app: cpu-throttled + spec: + containers: + - name: load-generator + image: ghcr.io/kedify/sample-load-generator + env: + - name: BASELINE_CPU_MILLICORES + value: "60" + - name: BASELINE_MEMORY_MIB + value: "96" + - name: SCHEDULE_JSON + value: '{"loop":true,"steps":[{"profile":"idle","durationSeconds":600},{"profile":"high","durationSeconds":300}]}' + resources: + requests: {cpu: 120m, memory: 160Mi} + limits: {cpu: 350m, memory: 760Mi} + readinessProbe: + httpGet: {path: /healthz, port: 8080} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: mixed-containers +spec: + replicas: 1 + selector: + matchLabels: + app: mixed-containers + template: + metadata: + labels: + app: mixed-containers + spec: + containers: + - name: application + image: ghcr.io/kedify/sample-load-generator + env: + - name: BASELINE_CPU_MILLICORES + value: "100" + - name: BASELINE_MEMORY_MIB + value: "300" + resources: + requests: {cpu: 125m, memory: 96Mi} + limits: {cpu: 500m, memory: 600Mi} + readinessProbe: + httpGet: {path: /healthz, port: 8080} + - name: sidecar + image: nginx:1.28-alpine + resources: + requests: {cpu: 300m, memory: 256Mi} + limits: {cpu: 500m, memory: 384Mi} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: bursty-unthrottled +spec: + replicas: 1 + selector: + matchLabels: + app: bursty-unthrottled + template: + metadata: + labels: + app: bursty-unthrottled + spec: + containers: + - name: load-generator + image: ghcr.io/kedify/sample-load-generator + env: + - name: BASELINE_CPU_MILLICORES + value: "60" + - name: BASELINE_MEMORY_MIB + value: "96" + - name: SCHEDULE_JSON + value: '{"loop":true,"steps":[{"profile":"idle","durationSeconds":660},{"profile":"high","durationSeconds":300}]}' + resources: + requests: {cpu: 120m, memory: 160Mi} + limits: {cpu: "1", memory: 760Mi} + readinessProbe: + httpGet: {path: /healthz, port: 8080} diff --git a/test-data/rightsizing/gpu/inference.yaml b/test-data/rightsizing/gpu/inference.yaml new file mode 100644 index 0000000..4f2b946 --- /dev/null +++ b/test-data/rightsizing/gpu/inference.yaml @@ -0,0 +1,66 @@ +apiVersion: v1 +kind: Namespace +metadata: + name: rightsizing-gpu +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: vllm +spec: + replicas: 0 + strategy: + type: Recreate + selector: + matchLabels: + app: vllm + template: + metadata: + labels: + app: vllm + spec: + nodeSelector: + kubernetes.io/os: linux + tolerations: + - key: sku + operator: Equal + value: gpu + effect: NoSchedule + containers: + - name: vllm + image: vllm/vllm-openai + args: + - --model=facebook/opt-125m + - --served-model-name=opt125m + - --enforce-eager + - --gpu-memory-utilization=0.35 + - --max-model-len=512 + - --max-num-seqs=32 + ports: + - name: http + containerPort: 8000 + resources: + requests: {cpu: "1", memory: 2Gi, nvidia.com/gpu: "1"} + limits: {cpu: "4", memory: 6Gi, nvidia.com/gpu: "1"} + startupProbe: + httpGet: {path: /health, port: http} + failureThreshold: 90 + periodSeconds: 10 + readinessProbe: + httpGet: {path: /health, port: http} + periodSeconds: 10 + volumeMounts: + - {name: shm, mountPath: /dev/shm} + volumes: + - name: shm + emptyDir: {medium: Memory, sizeLimit: 512Mi} +--- +apiVersion: v1 +kind: Service +metadata: + name: vllm +spec: + selector: + app: vllm + ports: + - {name: http, port: 8000, targetPort: http} diff --git a/test-data/rightsizing/gpu/kustomization.yaml b/test-data/rightsizing/gpu/kustomization.yaml new file mode 100644 index 0000000..a2950cb --- /dev/null +++ b/test-data/rightsizing/gpu/kustomization.yaml @@ -0,0 +1,8 @@ +apiVersion: kustomize.config.k8s.io/v1beta1 +kind: Kustomization +namespace: rightsizing-gpu +resources: + - inference.yaml +images: + - name: vllm/vllm-openai + digest: sha256:607442e407b0fea97f8a132a78b787c121a996dd4de181fa08e8da06e71ec2db From e530a609834de5619226b0a9838ad393ab23b581 Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Wed, 18 Nov 2026 21:34:15 +0100 Subject: [PATCH 2/5] Expand rightsizing fixtures for scaling and inference --- test-data/rightsizing/README.md | 55 +++++- test-data/rightsizing/cpu/batch.yaml | 74 ++++++++ test-data/rightsizing/cpu/behavior.yaml | 168 +++++++++++++++++++ test-data/rightsizing/cpu/kustomization.yaml | 6 + test-data/rightsizing/cpu/workloads.yaml | 2 +- test-data/rightsizing/gpu/kustomization.yaml | 7 + test-data/rightsizing/gpu/load.py | 64 +++++++ test-data/rightsizing/gpu/load.yaml | 28 ++++ 8 files changed, 398 insertions(+), 6 deletions(-) create mode 100644 test-data/rightsizing/cpu/batch.yaml create mode 100644 test-data/rightsizing/cpu/behavior.yaml create mode 100644 test-data/rightsizing/gpu/load.py create mode 100644 test-data/rightsizing/gpu/load.yaml diff --git a/test-data/rightsizing/README.md b/test-data/rightsizing/README.md index 713fe51..cd61a52 100644 --- a/test-data/rightsizing/README.md +++ b/test-data/rightsizing/README.md @@ -10,10 +10,11 @@ kubectl -n rightsizing get pods kubectl -n rightsizing top pods --containers ``` -Allow about 4 vCPUs and 8 GiB of allocatable capacity for the lab and your +Allow for a CPU node with at least 4 vCPUs and 8 GiB for the lab and your observability agents. The CPU workloads reuse the [load-generator sample](../../samples/load-generator) at a pinned image digest. CPU and memory settings are targets, so use measured usage when comparing tools. +The HPA and `kubectl top` need a working Kubernetes Metrics API. | Workload | Signal to look for | | --- | --- | @@ -21,13 +22,35 @@ CPU and memory settings are targets, so use measured usage when comparing tools. | `cpu-throttled` | Five-minute bursts capped at 350m despite a 900m target. Compare throttling and the CPU limit recommendation with `bursty-unthrottled`. | | `bursty-unthrottled` | The same high-load profile with room to reach its CPU target. Look for recommendations that preserve headroom for bursts. | | `mixed-containers` | Application memory usage exceeds its request while the idle nginx sidecar has oversized requests. Look for distinct per-container recommendations. | +| `startup-spike` | The same container starts on a 90-second CPU and memory spike, then drops to steady state. Use `kubectl -n rightsizing rollout restart deploy/startup-spike` to collect another startup sample. | +| `hpa-container` | A CPU utilization HPA scales to its two-replica cap using only the application container. Check whether a request change also changes the effective HPA target for that container. | +| `missing-resources` | nginx has no requests or limits. Check for missing-resource findings and sensible initial values. | +| `memory-growth` | Retains 8 MiB more every five minutes for 3 hours 20 minutes, then holds. Check for sustained growth after warm-up and whether the tool avoids a premature limit reduction. Restart the Deployment to replay the ramp. | +| `short-batch` | A 45-second CronJob runs every 10 minutes. Check whether usage is collected and grouped across Job runs. | +| `memory-oom` | A CronJob intentionally exceeds its own 64 MiB memory limit twice an hour. Check for `OOMKilled` and a higher memory limit recommendation. | +| `mixed-containers` PDB | The only replica is protected from voluntary eviction by `minAvailable: 1`. Check whether the tool explains the drain blocker. | +| `unschedulable-selector` | A Pod intentionally stays Pending because its selector matches no node. Check for an explicit scheduling reason. | + +Trigger the batch cases on demand with unique Job names. The memory Job is +expected to fail, and the pending fixture is expected to stay Pending. Actual +node consolidation needs at least two eligible nodes. + +```bash +kubectl -n rightsizing create job --from=cronjob/short-batch short-batch-check +kubectl -n rightsizing create job --from=cronjob/memory-oom memory-oom-check +kubectl -n rightsizing get jobs,hpa,pdb +kubectl -n rightsizing get events --sort-by=.lastTimestamp +``` ## Optional NVIDIA inference This fixture reuses the [vLLM sample's model](../../samples/vllm-autoscaling). It needs a node advertising `nvidia.com/gpu`, plus DCGM workload metrics for -GPU utilization and framebuffer memory. It defaults to zero replicas so CPU -labs can keep the configuration without reserving a GPU. +GPU utilization and framebuffer memory. Verify that DCGM exposes +`DCGM_FI_DEV_GPU_UTIL` and `DCGM_FI_DEV_FB_USED`, and that total and driver-reserved +framebuffer memory are available for tools that use those as the denominator. +The Deployment defaults to zero replicas so CPU labs can keep the configuration +without reserving a GPU. ```bash kubectl apply -k test-data/rightsizing/gpu @@ -44,8 +67,18 @@ curl -fsS http://localhost:8000/v1/completions \ -d '{"model":"opt125m","prompt":"The capital of France is","max_tokens":32}' ``` -Compare compute activity with framebuffer allocation while idle and under load. -vLLM preallocates KV cache, so GPU memory use can stay high while compute is idle. +Observe an idle baseline first, then run the three-minute burst from inside the +cluster. The benchmark reports completed tokens per second, p95 request latency, +and errors. Use vLLM's `/metrics` for queue depth, KV cache utilization and time +to first token. Compare those with DCGM compute activity and framebuffer +allocation. vLLM preallocates KV cache, so GPU memory can stay allocated while +compute is idle. + +```bash +kubectl -n rightsizing-gpu create job --from=cronjob/vllm-load vllm-load-check +kubectl -n rightsizing-gpu logs -f job/vllm-load-check +``` + When done, scale the Deployment back to zero. If you added a dedicated GPU node pool, scale that pool back down separately to stop billing for its nodes. @@ -55,3 +88,15 @@ Record the tool's observation window, sample coverage, current and suggested requests and limits, reason, estimated savings, and any prerequisites for applying the advice. Check usage and restart counts alongside recommendations. Use the same cluster state and observation window when comparing two tools. +For Kedify Insights on a connected cluster with namespace opt-in enabled, label +the fixture namespaces: + +```bash +kubectl label namespace rightsizing insights.kedify.io/scrape=true --overwrite +# If you applied the GPU fixture: +kubectl label namespace rightsizing-gpu insights.kedify.io/scrape=true --overwrite +``` + +For safe HPA replay, compare the effective CPU target in millicores before and +after changing application CPU requests. Leave the sidecar out of this +calculation because the HPA metric targets the application container. diff --git a/test-data/rightsizing/cpu/batch.yaml b/test-data/rightsizing/cpu/batch.yaml new file mode 100644 index 0000000..fd272e4 --- /dev/null +++ b/test-data/rightsizing/cpu/batch.yaml @@ -0,0 +1,74 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: short-batch +spec: + schedule: "*/10 * * * *" + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 4 + failedJobsHistoryLimit: 1 + jobTemplate: + spec: + activeDeadlineSeconds: 90 + ttlSecondsAfterFinished: 3600 + backoffLimit: 0 + template: + metadata: + labels: + app: short-batch + spec: + restartPolicy: Never + containers: + - name: worker + image: python + command: + - python + - -c + - | + import hashlib + import time + + data = bytearray(b"x") * (96 * 1024 * 1024) + block = memoryview(data)[:1024 * 1024] + deadline = time.monotonic() + 45 + while time.monotonic() < deadline: + hashlib.sha256(block).digest() + resources: + requests: {cpu: 100m, memory: 64Mi} + limits: {cpu: 250m, memory: 192Mi} +--- +apiVersion: batch/v1 +kind: CronJob +metadata: + name: memory-oom +spec: + schedule: "7,37 * * * *" + concurrencyPolicy: Forbid + successfulJobsHistoryLimit: 1 + failedJobsHistoryLimit: 3 + jobTemplate: + spec: + activeDeadlineSeconds: 90 + ttlSecondsAfterFinished: 7200 + backoffLimit: 0 + template: + metadata: + labels: + app: memory-oom + spec: + restartPolicy: Never + containers: + - name: worker + image: python + command: + - python + - -c + - | + import time + + time.sleep(20) + data = bytearray(b"x") * (112 * 1024 * 1024) + time.sleep(10) + resources: + requests: {cpu: 25m, memory: 32Mi} + limits: {cpu: 150m, memory: 64Mi} diff --git a/test-data/rightsizing/cpu/behavior.yaml b/test-data/rightsizing/cpu/behavior.yaml new file mode 100644 index 0000000..c35a954 --- /dev/null +++ b/test-data/rightsizing/cpu/behavior.yaml @@ -0,0 +1,168 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: startup-spike +spec: + replicas: 1 + selector: + matchLabels: + app: startup-spike + template: + metadata: + labels: + app: startup-spike + spec: + containers: + - name: load-generator + image: ghcr.io/kedify/sample-load-generator + env: + - name: BASELINE_CPU_MILLICORES + value: "50" + - name: BASELINE_MEMORY_MIB + value: "64" + - name: SCHEDULE_JSON + value: '{"steps":[{"profile":"high","durationSeconds":90},{"profile":"idle","durationSeconds":30}]}' + resources: + requests: {cpu: 200m, memory: 256Mi} + limits: {cpu: "1", memory: 768Mi} + readinessProbe: + httpGet: {path: /healthz, port: 8080} + initialDelaySeconds: 90 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hpa-container +spec: + selector: + matchLabels: + app: hpa-container + template: + metadata: + labels: + app: hpa-container + spec: + containers: + - name: application + image: ghcr.io/kedify/sample-load-generator + env: + - name: BASELINE_CPU_MILLICORES + value: "230" + - name: BASELINE_MEMORY_MIB + value: "64" + resources: + requests: {cpu: 100m, memory: 96Mi} + limits: {cpu: 500m, memory: 192Mi} + readinessProbe: + httpGet: {path: /healthz, port: 8080} + - name: sidecar + image: nginx + resources: + requests: {cpu: 100m, memory: 96Mi} + limits: {cpu: 250m, memory: 192Mi} +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: hpa-container +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: hpa-container + minReplicas: 1 + maxReplicas: 2 + metrics: + - type: ContainerResource + containerResource: + name: cpu + container: application + target: + type: Utilization + averageUtilization: 55 +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: missing-resources +spec: + replicas: 1 + selector: + matchLabels: + app: missing-resources + template: + metadata: + labels: + app: missing-resources + spec: + containers: + - name: nginx + image: nginx +--- +apiVersion: policy/v1 +kind: PodDisruptionBudget +metadata: + name: mixed-containers +spec: + minAvailable: 1 + selector: + matchLabels: + app: mixed-containers +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: unschedulable-selector +spec: + replicas: 1 + selector: + matchLabels: + app: unschedulable-selector + template: + metadata: + labels: + app: unschedulable-selector + spec: + nodeSelector: + rightsizing.test/node-class: fixture-only + containers: + - name: nginx + image: nginx + resources: + requests: {cpu: 25m, memory: 32Mi} + limits: {cpu: 100m, memory: 96Mi} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: memory-growth +spec: + replicas: 1 + selector: + matchLabels: + app: memory-growth + template: + metadata: + labels: + app: memory-growth + spec: + containers: + - name: worker + image: python + command: + - python + - -u + - -c + - | + import time + + chunks = [bytearray(b"x") * (24 * 1024 * 1024)] + for _ in range(40): + time.sleep(300) + chunks.append(bytearray(b"x") * (8 * 1024 * 1024)) + print(f"Retained {(len(chunks) - 1) * 8 + 24} MiB") + while True: + time.sleep(300) + resources: + requests: {cpu: 25m, memory: 96Mi} + limits: {cpu: 150m, memory: 448Mi} diff --git a/test-data/rightsizing/cpu/kustomization.yaml b/test-data/rightsizing/cpu/kustomization.yaml index 3fa355d..03707c3 100644 --- a/test-data/rightsizing/cpu/kustomization.yaml +++ b/test-data/rightsizing/cpu/kustomization.yaml @@ -4,6 +4,12 @@ namespace: rightsizing resources: - namespace.yaml - workloads.yaml + - behavior.yaml + - batch.yaml images: - name: ghcr.io/kedify/sample-load-generator digest: sha256:b36671f195698e6c7405b04c92833376d4303047d2dd2db56b7abdebfabdd95d + - name: nginx + digest: sha256:a8b39bd9cf0f83869a2162827a0caf6137ddf759d50a171451b335cecc87d236 + - name: python + digest: sha256:9ef1a599f863231c3d91e941389bfdc4a2d6070557243d54df1a4e57015b960e diff --git a/test-data/rightsizing/cpu/workloads.yaml b/test-data/rightsizing/cpu/workloads.yaml index e476293..2173a90 100644 --- a/test-data/rightsizing/cpu/workloads.yaml +++ b/test-data/rightsizing/cpu/workloads.yaml @@ -84,7 +84,7 @@ spec: readinessProbe: httpGet: {path: /healthz, port: 8080} - name: sidecar - image: nginx:1.28-alpine + image: nginx resources: requests: {cpu: 300m, memory: 256Mi} limits: {cpu: 500m, memory: 384Mi} diff --git a/test-data/rightsizing/gpu/kustomization.yaml b/test-data/rightsizing/gpu/kustomization.yaml index a2950cb..14c6024 100644 --- a/test-data/rightsizing/gpu/kustomization.yaml +++ b/test-data/rightsizing/gpu/kustomization.yaml @@ -3,6 +3,13 @@ kind: Kustomization namespace: rightsizing-gpu resources: - inference.yaml + - load.yaml +configMapGenerator: + - name: vllm-benchmark + files: + - load.py images: - name: vllm/vllm-openai digest: sha256:607442e407b0fea97f8a132a78b787c121a996dd4de181fa08e8da06e71ec2db + - name: python + digest: sha256:9ef1a599f863231c3d91e941389bfdc4a2d6070557243d54df1a4e57015b960e diff --git a/test-data/rightsizing/gpu/load.py b/test-data/rightsizing/gpu/load.py new file mode 100644 index 0000000..566e3bf --- /dev/null +++ b/test-data/rightsizing/gpu/load.py @@ -0,0 +1,64 @@ +"""Run a bounded, concurrent load phase against the lab vLLM Service.""" + +import json +import math +import time +from concurrent.futures import ThreadPoolExecutor +from urllib.error import URLError +from urllib.request import Request, urlopen + +URL = "http://vllm:8000/v1/completions" +WORKERS = 8 +DURATION_SECONDS = 180 + + +def send_requests(deadline, worker): + latencies = [] + generated_tokens = 0 + failures = 0 + sequence = 0 + while time.monotonic() < deadline: + sequence += 1 + body = json.dumps({ + "model": "opt125m", + "prompt": f"Request {worker}-{sequence}. The capital of France is", + "temperature": 0, + "max_tokens": 64, + "ignore_eos": True, + }).encode() + request = Request(URL, data=body, headers={"Content-Type": "application/json"}) + started = time.monotonic() + try: + with urlopen(request, timeout=15) as response: + generated_tokens += json.load(response)["usage"]["completion_tokens"] + latencies.append(time.monotonic() - started) + except (URLError, TimeoutError, ValueError, KeyError) as error: + if failures == 0: + print(f"Worker {worker} first failure: {error}", flush=True) + failures += 1 + time.sleep(1) + return latencies, generated_tokens, failures + + +def main(): + started = time.monotonic() + deadline = started + DURATION_SECONDS + with ThreadPoolExecutor(max_workers=WORKERS) as executor: + results = list(executor.map(lambda worker: send_requests(deadline, worker), range(WORKERS))) + + elapsed = time.monotonic() - started + latencies = sorted(latency for samples, _, _ in results for latency in samples) + tokens = sum(tokens for _, tokens, _ in results) + failures = sum(failures for _, _, failures in results) + p95 = latencies[math.ceil(0.95 * len(latencies)) - 1] if latencies else None + print(json.dumps({ + "successful_requests": len(latencies), + "failed_requests": failures, + "completion_tokens_per_second": round(tokens / elapsed, 2), + "p95_request_seconds": round(p95, 3) if p95 is not None else None, + }), flush=True) + return 1 if failures or not latencies else 0 + + +if __name__ == "__main__": + raise SystemExit(main()) diff --git a/test-data/rightsizing/gpu/load.yaml b/test-data/rightsizing/gpu/load.yaml new file mode 100644 index 0000000..1ff56de --- /dev/null +++ b/test-data/rightsizing/gpu/load.yaml @@ -0,0 +1,28 @@ +apiVersion: batch/v1 +kind: CronJob +metadata: + name: vllm-load +spec: + schedule: "0 0 * * *" + suspend: true + jobTemplate: + spec: + activeDeadlineSeconds: 300 + ttlSecondsAfterFinished: 3600 + backoffLimit: 0 + template: + spec: + restartPolicy: Never + containers: + - name: client + image: python + command: [python, /bench/load.py] + resources: + requests: {cpu: 50m, memory: 64Mi} + limits: {cpu: 500m, memory: 192Mi} + volumeMounts: + - {name: bench, mountPath: /bench, readOnly: true} + volumes: + - name: bench + configMap: + name: vllm-benchmark From 40f0441549edf44e64ad978be8e97da81df3c074 Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Wed, 18 Nov 2026 21:38:30 +0100 Subject: [PATCH 3/5] Exercise replica floor and inference queueing --- test-data/rightsizing/README.md | 6 ++-- test-data/rightsizing/cpu/behavior.yaml | 46 ++++++++++++++++++++++++ test-data/rightsizing/gpu/inference.yaml | 2 +- 3 files changed, 51 insertions(+), 3 deletions(-) diff --git a/test-data/rightsizing/README.md b/test-data/rightsizing/README.md index cd61a52..f311959 100644 --- a/test-data/rightsizing/README.md +++ b/test-data/rightsizing/README.md @@ -24,6 +24,7 @@ The HPA and `kubectl top` need a working Kubernetes Metrics API. | `mixed-containers` | Application memory usage exceeds its request while the idle nginx sidecar has oversized requests. Look for distinct per-container recommendations. | | `startup-spike` | The same container starts on a 90-second CPU and memory spike, then drops to steady state. Use `kubectl -n rightsizing rollout restart deploy/startup-spike` to collect another startup sample. | | `hpa-container` | A CPU utilization HPA scales to its two-replica cap using only the application container. Check whether a request change also changes the effective HPA target for that container. | +| `hpa-idle-floor` | A quiet workload stays at its two-replica minimum. Check for a minimum replica recommendation and whether it explains the availability tradeoff. | | `missing-resources` | nginx has no requests or limits. Check for missing-resource findings and sensible initial values. | | `memory-growth` | Retains 8 MiB more every five minutes for 3 hours 20 minutes, then holds. Check for sustained growth after warm-up and whether the tool avoids a premature limit reduction. Restart the Deployment to replay the ramp. | | `short-batch` | A 45-second CronJob runs every 10 minutes. Check whether usage is collected and grouped across Job runs. | @@ -68,8 +69,9 @@ curl -fsS http://localhost:8000/v1/completions \ ``` Observe an idle baseline first, then run the three-minute burst from inside the -cluster. The benchmark reports completed tokens per second, p95 request latency, -and errors. Use vLLM's `/metrics` for queue depth, KV cache utilization and time +cluster. Eight clients send requests while vLLM processes up to four sequences +at once, creating opportunities to observe queueing. The benchmark reports +completed tokens per second, p95 request latency, and errors. Use vLLM's `/metrics` for queue depth, KV cache utilization and time to first token. Compare those with DCGM compute activity and framebuffer allocation. vLLM preallocates KV cache, so GPU memory can stay allocated while compute is idle. diff --git a/test-data/rightsizing/cpu/behavior.yaml b/test-data/rightsizing/cpu/behavior.yaml index c35a954..f416179 100644 --- a/test-data/rightsizing/cpu/behavior.yaml +++ b/test-data/rightsizing/cpu/behavior.yaml @@ -166,3 +166,49 @@ spec: resources: requests: {cpu: 25m, memory: 96Mi} limits: {cpu: 150m, memory: 448Mi} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: hpa-idle-floor +spec: + selector: + matchLabels: + app: hpa-idle-floor + template: + metadata: + labels: + app: hpa-idle-floor + spec: + containers: + - name: load-generator + image: ghcr.io/kedify/sample-load-generator + env: + - name: BASELINE_CPU_MILLICORES + value: "20" + - name: BASELINE_MEMORY_MIB + value: "64" + resources: + requests: {cpu: 100m, memory: 96Mi} + limits: {cpu: 300m, memory: 192Mi} + readinessProbe: + httpGet: {path: /healthz, port: 8080} +--- +apiVersion: autoscaling/v2 +kind: HorizontalPodAutoscaler +metadata: + name: hpa-idle-floor +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: hpa-idle-floor + minReplicas: 2 + maxReplicas: 3 + metrics: + - type: Resource + resource: + name: cpu + target: + type: Utilization + averageUtilization: 80 diff --git a/test-data/rightsizing/gpu/inference.yaml b/test-data/rightsizing/gpu/inference.yaml index 4f2b946..ecce9c6 100644 --- a/test-data/rightsizing/gpu/inference.yaml +++ b/test-data/rightsizing/gpu/inference.yaml @@ -35,7 +35,7 @@ spec: - --enforce-eager - --gpu-memory-utilization=0.35 - --max-model-len=512 - - --max-num-seqs=32 + - --max-num-seqs=4 ports: - name: http containerPort: 8000 From e8c03806b415318acfb17c71f32bf5eff5fe89d7 Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Wed, 18 Nov 2026 21:46:11 +0100 Subject: [PATCH 4/5] Prevent Kubernetes service links from breaking vLLM --- test-data/rightsizing/gpu/inference.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/test-data/rightsizing/gpu/inference.yaml b/test-data/rightsizing/gpu/inference.yaml index ecce9c6..747e1b3 100644 --- a/test-data/rightsizing/gpu/inference.yaml +++ b/test-data/rightsizing/gpu/inference.yaml @@ -19,6 +19,8 @@ spec: labels: app: vllm spec: + # Prevent the Service from injecting VLLM_PORT into the engine. + enableServiceLinks: false nodeSelector: kubernetes.io/os: linux tolerations: From 38137049ca1b76dcffa4a89eb60582c36480490f Mon Sep 17 00:00:00 2001 From: Zbynek Roubalik Date: Thu, 19 Nov 2026 13:28:04 +0100 Subject: [PATCH 5/5] Patch NGINX in CPU rightsizing lab fixtures (#1) Signed-off-by: Zbynek Roubalik --- test-data/rightsizing/cpu/kustomization.yaml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test-data/rightsizing/cpu/kustomization.yaml b/test-data/rightsizing/cpu/kustomization.yaml index 03707c3..c218ada 100644 --- a/test-data/rightsizing/cpu/kustomization.yaml +++ b/test-data/rightsizing/cpu/kustomization.yaml @@ -10,6 +10,7 @@ images: - name: ghcr.io/kedify/sample-load-generator digest: sha256:b36671f195698e6c7405b04c92833376d4303047d2dd2db56b7abdebfabdd95d - name: nginx - digest: sha256:a8b39bd9cf0f83869a2162827a0caf6137ddf759d50a171451b335cecc87d236 + newTag: 1.30.7-alpine + digest: sha256:bef154735288bc38d99fac41ae63730684bcc661503673a04a0f9bc526ba8598 - name: python digest: sha256:9ef1a599f863231c3d91e941389bfdc4a2d6070557243d54df1a4e57015b960e