cd /news/ai-agents/testing-kubernetes-vulnerability-sca… · home › topics › ai-agents › article
[ARTICLE · art-179131] src=dev.to ↗ pub= topic=ai-agents verified=true sentiment=↑ positive

Testing Kubernetes Vulnerability Scanning with AI: What We Built and What We Found

A two-person team working with an AI coding agent built vulnbench, a FastAPI/SQLite web console that runs repeatable memory and vulnerability-scan benchmarks against the Uptycs osquery agent on Kubernetes and OpenShift clusters. Over four weeks the console went through 179 gated releases (v0.1 to v0.106.17) and 52 benchmark runs across two clusters, with humans approving every change to test conditions, agent binaries or cloud queries. The work traced the agent's OOM loop to root causes, including the process_envs query as a memory trigger, by aligning per-second memory probes, query timings and log lines on a shared UTC timeline.

recommendation

When an agent OOMs, timestamp memory probes, query metrics and logs on one axis and sweep memory limits to find the smallest that survives a full scan.

more in playbook: Running AI in production
by read9 min views2 publishedDec 1, 2026

In four weeks, two of us and an AI coding agent built a test console, ran 52 benchmark runs on two Kubernetes clusters, and turned an unexplained agent OOM loop into a list of root causes with evidence.

The question sounded simple: why does the Uptycs osquery agent on our OpenShift lab cluster keep hitting its memory limit? The agent scans every container on a node for vulnerabilities. A scan parses hundreds of thousands of CVE templates, uploads results to the cloud, and shares one pod memory limit with everything else the agent does.

Answering that by hand means watching memory second by second, matching it to agent log lines, and repeating under different loads and limits. That is slow and error-prone for people, and easy to get subtly wrong. So we made AI do the repetitive engineering, and kept people on the decisions.

vulnbench is a single web console that runs a test, records everything the agent and the node do, and builds the report. It is one FastAPI process with SQLite and a plain-JavaScript UI, running on a lab VM.

A run is one test definition: which clusters and nodes, how long, which load, which Uptycs queries to fire, and the agent's memory limit. The console enforces one run at a time and refuses a second with the running test's details.

The console talks to both clusters through kubectl and SSH, to the Uptycs cloud through read-only queries, and to the LLM through an AI gateway.

AI worked at three levels. It built the tool, it ran and read the tests, and it sits inside the console for anyone who uses it.

People kept the decisions. Changing a test's conditions, swapping an agent binary, or firing a query at the cloud needed an explicit OK each time.

The console went from v0.1 on 2026-11-06 to v0.106.17 on 2026-11-30: 179 logged releases, each through a test gate.

Tool or feature What it does Why we needed it
Test config + runner Versioned test definitions; one run slot; live log, ETA and ticker Repeatable runs that anyone can start and compare
fdload Multi-arch load generator: file descriptors, sockets, processes, env vars, CPU, per node Real nodes are busy; an idle-node benchmark hides costs
Memory-limit sweep and soak Holds or steps the agent's memory limit for hours, then restores it Find the smallest limit that survives a full scan
qbench Runs query variants side by side Prove a cheaper SQL returns the same rows
Query monitor Every scheduled and live query: start, end, CPU, memory before, peak, kept Tie each memory jump to the query that caused it
Vulnerability report Per scan: type (full, high, incremental), phases, download, scan and upload time, CVE counts See where a scan spends time and memory
Flow The queries and log lines around any error, on one timeline Answer "what was the agent doing when this broke?"
Processes and Environment pages Per-node process and env-var load, and what the agent saw process_envs turned out to be an OOM trigger
Agent-pod config Memory and CPU limits and requests per test, restored after the run Test 350Mi, 512Mi and 1000Mi without hand edits
Upgrade Lists agent versions from the Uptycs API, downloads and applies them Retest each new build the same way
Multi-cluster One test across clusters and nodes, one combined report, per-cluster tabs Compare x86 OpenShift with ppc64le
Reports Test report, classic report, vulnerability report, resource trends; doc export Share results without opening the console
Chat agent LLM with console tools, confirm-before-change, token count per answer Ask questions of the data in plain language

Every signal carries a UTC timestamp and a node, so a memory spike, a query and a log line can be laid on the same axis. That alignment is what made root causes visible.

Source Recorded Interval
Probe osqueryd worker and uptycs-protect memory (RSS, anon) and CPU, worker PID 1 s
Pod stats Pod memory total vs anon vs page cache, restarts, OOM kills, osquery.db size 5 min and per event
Query monitor Each query's run time, CPU, memory before, peak and kept; overlap with live queries Per query run
Agent log Scan phases per OS, template downloads, result batches, upload errors, watchdog kills Continuous
Watcher Worker restarts with old and new PID Continuous
Node and load Node CPU, load average, file opens, TCP connects, process starts from fdload Per run
Kubernetes events Pod replaced, OOMKilled, node not ready Per event
Uptycs cloud Scan results: rows, CVE counts per system, scan type; read-only queries Per scan

At run end the console captures every node's agent logs and diagnostics into the run folder. The reports, alerts and AI notes are built from that folder, so a run can be re-analysed after the cluster has moved on.

The biggest single cost is a full vulnerability scan: one CentOS 7 container took the agent's worker from 125 MB to 418 MB in 36 seconds. Below are the issues we raised, each with the evidence the telemetry gave us.

Issue Evidence Impact
Scan filtered to one container also scans the host Reported 684 packages; the container has 148, the host 496; host OS templates were downloaded too Per-container scans cost a host scan each
Agent's own memory figure understates the peak Agent "max watermark" +144 MB vs measured +293 MB Internal metrics can't be trusted for sizing
Scan phases peak high CentOS 9 phase +235 MiB; CentOS template set is 35.7 MB of JSON, about 495,000 templates OOM at 512Mi during full scans
process_envs under process load A worker OOM-killed every 15 min with 50 load processes Busy nodes OOM on a routine query
Result batches exceed the cloud's body limit 4 × "body limit exceeded" in the RHEL 7.9 phase, 8,192 vulns in batches of 2,048 Some scan results may never reach the cloud
Watchdog never acts Auto-sized to 1,440 MB, above the 1000Mi pod limit; the memory-limit flag ignored The kernel kills the pod before the agent protects itself
Full scan on ppc64le under CPU load Unloaded: 542 s, 8,286 packages, 66,329 vulns. At 50% CPU it passed 30 min and the watchdog killed it No full scan completes on a busy Power node
ppc chart default too small 500Mi / 1 CPU was OOM-killed hourly; raised to 1000Mi / 4 CPU Default install fails on Power
Issue Evidence Impact
serial-getty restarting every ~10 s on every node wtmp 36 MB, 93k rows, +8.4k rows a day; hourly last query averages 44 MB Agent cost grows every day with no change
Incremental scans refused before a full scan "Issued an incremental scan prior to a complete scan" until one full scan completes A node can go hours with no vulnerability data
Cloud sync query times out during a full scan Times out while the agent keeps scanning The cloud's view lags the agent's
Silent death after OOM Container "Running" with no osqueryd for 3 days No alert; looks healthy

The AI found and fixed most of these, but several reached a run before they were caught.

AI turned a months-long investigation into a four-week one, mainly by removing the wait between asking a question and having the tool to answer it.

last query growing every day. Not one of those steps was in the original question. AI is fast and thorough, but it checks what it is told to check.

The agent built into the console earned its place when it stopped waiting to be asked. It watches the cluster, investigates incidents on its own, and reports what it finds.

The AI works only from evidence cut to the incident window. Its result is an alert, and any change it suggests waits for a person.

Capability How it works What it gave us
Incident investigation A watcher checks for agent OOM kills, restarts and NotReady nodes; on each it collects pod status, agent logs from 15 min before, events, memory history and the node journal, then asks the AI for cause and next step An OOM at 3 a.m. arrives with its evidence and a likely cause, not just a restart count
Findings as alerts Each AI finding becomes an alert on the ticker and Alerts page; a failed AI call retries 3 times and raises its own alert Nothing the AI found is lost silently. We added this after an OOM had been investigated but nobody was told
Read-only tools About two dozen tools: runs, compare, query monitor, agent log, flow, threat-indicator downloads and scans Answers cite real rows and log lines instead of guesses
Confirm before change Any write (config, test, kubectl, helm) stops at a Confirm / Decline card Anyone can use the chat on a shared lab without risk
Run comparison The AI explains the difference between two runs: memory, scan times, alerts Faster "did this build help?" answers
UI sweep and self-fix A sweep finds browser errors, failed API calls and server tracebacks; a fixer works in a separate git worktree, runs the tests, and proposes the change Small UI bugs got fixed without a person opening the code
Token frugality Plain commands bypass the LLM; answer and tool caches; prompt caching; rolling history; per-chat budget; tokens shown on every message Cost stays visible and low; repeated questions cost 0 tokens

| Measure | Value |

|---|---|
| Calendar time | 2026-11-03 to 2026-11-30 | 

| Benchmark runs | 52, up to 24 h each | | Clusters | 2: OpenShift on x86 (5 nodes), kubeadm on ppc64le (1 node) | | Console releases | 179, v0.1 to v0.106.17 | | Requirements logged | About 170 | | Automated tests per change | 444 API, 62 browser, plus Go tests for the load tool | | Agent issues raised | 8 in the agent, 4 in the cluster and cloud |

── more in #ai-agents 4 stories · sorted by recency
── more on @uptycs 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain — perfect for shipping the agent you just read about.

$git push zahid main
→ Live at https://your-agent.zahid.host ✓
Get free account → Pricing
from €0/mo · no card required
LIVE [news/testing-kubernetes-v…] indexed:0 read:9min 2026-12-01 · —