The Registry Label Lies: When the Kubelet and the Scanner Disagree

Measured on 2026-09-12: VulnerabilityReports made it look like 8 of 91 images were Harbor-served; 44 of 91 actually were. The dashboard understated Harbor coverage roughly six-fold — reading as though the routing work had failed when it had landed.

The Registry Label Lies: When the Kubelet and the Scanner Disagree

Two weeks into the routing campaign, the dashboard told a discouraging story: registry coverage on Harbor had barely moved. The routing work had landed — the dashboard was wrong. Measured on 2026-09-12: the reports implied 8 of 91 images were Harbor-served; the truth was 44 of 91. A six-fold understatement.

Why the report and the kubelet disagree

A VulnerabilityReport is written per workload, and trivy-operator takes the image reference from the workload's pod template. The Kyverno rewrite lands on the created Pod (autogen disabled, previous post), and never modifies the immutable template. So:

  • the template says ghcr.io/cloudnative-pg/postgresql:18 — what the report sees;
  • the Pod says harbor.private.example.com/ghcr/cloudnative-pg/postgresql:18 — what the kubelet pulls.

The scanner reports the manifest; the cluster serves the rewrite. Both are "correct." Only one describes reality.

What the reports said vs what the kubelet did
What the reports said vs what the kubelet did

8/91 vs 44/91 — and the fallback detector underneath: watch cluster_exporter_pod_resolved_digests.

The fix: join on digest, not on registry string

vuln-exporter therefore lists Pods and joins on the image digest — safe because a Harbor proxy cache relays the upstream manifest byte-for-byte, so both routes resolve to the same digest (verified on cloudnative-pg: sha256:0dfff19b… via either path). Only attribution ever differed; no CVE count was ever affected.

If pod listing fails, the exporter falls back to the report's registry rather than failing the refresh — and a metric exists to catch exactly that: cluster_exporter_pod_resolved_digests dropping to 0 while images run means the fallback is active and Harbor coverage is understated again.

Measuring the gap yourself

The 8/91 vs 44/91 measurement is reproducible with two commands, and running them is the fastest way to internalize why they disagree:

# what the reports claim (template registry)
kubectl get vulnerabilityreports -A -o json | jq \
  '[.items[].report.artifact.registry] | group_by(.) | map({(.[0]): length}) | add'

# what the kubelet actually pulls (pod registry)
kubectl get pods -A -o jsonpath='{range .items[*]}{.spec.containers[*].image}{"\n"}{end}' \
  | tr ' ' '\n' | grep -c '^harbor.private.example.com/'

The first number moves when routing lands slowly or not at all (templates are immutable); the second moves immediately as pods restart. Any dashboard or alert built on the first number will understate routing progress by the exact fraction of workloads that have not yet rolled — which, for a StatefulSet-heavy estate, is most of them for a long time.

Why digest-joining is safe, precisely

The exporter joins Pods to reports on the image digest, and the safety argument is a property of proxy caches: a pull-through cache relays the upstream manifest byte-for-byte, so the digest resolved via Harbor equals the digest resolved via the upstream registry. This was verified directly on cloudnative-pg — sha256:0dfff19b… via either path — before the join shipped. If a cache ever mutated manifests (some do, for media types), the join would break silently; the exporter's fallback metric (cluster_exporter_pod_resolved_digests) is the tripwire: it dropping to 0 while images run means pod listing failed and the old, lying attribution is back.

The design pattern: measure the actor, not the declarer

The generalizable lesson outlives the specifics: when two sources describe the same fact, weight them by who acts on the fact. The kubelet acts on the Pod's image; the scanner merely describes the template's. The same pattern appears elsewhere in this cluster — Velero's schedules vs actual backups (the schedule declares, the backupstoragelocation acts), the Kustomization's Ready vs the HelmRelease's health (the parent declares, the release acts). In each case the fix was the same: measure the component that does the thing, and treat the declarer as documentation.

Next: the wasted candidate — patching an image nobody runs.