The goal is fewer risky images, not more reports
Installing a scanner is easy. Making it useful is the work. Plenty of teams switch on image scanning, receive thousands of findings, decide it is too noisy, and stop looking. The vulnerabilities did not go away; the signal did.
Our approach to Kubernetes image vulnerability scanning, part of our Kubernetes consulting service, is to put scanning where it changes behaviour, set a policy people can live with, and shrink the underlying problem at source. It connects directly to your CI/CD pipeline and to container work.
Three places to scan
| Stage | What it catches | Why it matters |
|---|---|---|
| CI, before push | Vulnerabilities in the image you are about to ship | Cheapest place to fix, tied to the commit |
| Registry, scheduled | New CVEs in images already stored | Old tags are still deployable |
| Cluster, continuous | What is running right now | Shows real exposure, including images nobody rebuilt |
Doing only the first leaves a blind spot: an image built six months ago and untouched since was clean when built and is not now.
Trivy or Snyk
Trivy is open source, runs as a single binary and scans OS packages, language dependencies, infrastructure code and exposed secrets. Snyk Container is a commercial product with a strong developer workflow, base image upgrade recommendations and managed prioritisation. They are not exclusive; some teams use Trivy in pipelines and an enterprise tool for reporting.
| Concern | Trivy | Snyk |
|---|---|---|
| Cost | Free | Paid tiers |
| Setup in CI | One step | One step plus account and token |
| Prioritisation and fix advice | Basic (fixed version info) | Richer, with base image suggestions |
| In-cluster scanning | Trivy Operator | Snyk controller |
| Support | Community | Vendor |
We choose with you based on budget, compliance expectations and how much triage effort your team can absorb.
A pipeline step that behaves sensibly
A GitHub Actions job scanning a freshly built image and failing only on fixable high and critical findings:
- name: Scan image
uses: aquasecurity/[email protected]
with:
image-ref: ghcr.io/example-org/api:${{ github.sha }}
severity: CRITICAL,HIGH
ignore-unfixed: true
exit-code: "1"
format: table
Pin the action to a version you have verified. ignore-unfixed keeps the pipeline from failing on issues nobody can patch yet. For the cluster side, the Trivy Operator runs as a Kubernetes operator and publishes vulnerability reports as custom resources you can alert on.
Policy: what blocks, what tickets
A policy we commonly start with:
- Block critical and high findings with an available fix, in production-bound images.
- Ticket medium findings with an owner and a time limit.
- Record everything else, reviewed periodically.
- Exceptions require a reason, an owner and an expiry date.
Also consider exploitability. A critical CVE in a library your service never loads is lower priority than a high severity flaw in an internet-facing path. Context beats raw severity, which is where tools with reachability analysis or VEX data help.
The bigger lever: fewer packages
Most findings come from the base image. Cutting them is more effective than triaging them:
- Use minimal or distroless images, and multi-stage builds so compilers and package managers do not ship.
- Pin base image digests and update them regularly through Renovate or Dependabot.
- Rebuild on a schedule so base image fixes reach production even when application code is unchanged.
- Run as non-root with a read-only filesystem to limit the impact of whatever remains.
Worked example: reading a first scan honestly
On a first baseline scan, expect a long list and resist the urge to fix it top to bottom. We group findings by image layer instead. Typically one or two base images account for most of the volume, so moving those to a current, slimmer base clears a large share in a single change. The remainder splits into application dependencies, which Renovate or Dependabot can raise as pull requests, and unfixed operating system packages, which go on the record with an expiry date.
Then we look at exposure. Which of the remaining images face the internet, run privileged, or hold credentials? Those get fixed first, regardless of raw severity ordering. This turns an overwhelming report into a short, owned list.
Enforcement in the cluster
Scanning tells you what is wrong. Admission policy can stop the worst from running. With Kyverno or a similar engine you can require images to come from approved registries, forbid the latest tag, and, with signing through Cosign, verify that images were built by your pipeline. Pair this with least privilege access so a compromised workload has little to work with. Because GitOps records which image digest runs where, answering “where is this vulnerable image deployed?” takes minutes.
Trade-offs and when not to over-engineer
- Very early stage: a single Trivy step in CI with a lenient policy delivers most of the value. Do not build a vulnerability management programme for two services.
- Regulated industries: you may need evidence, retention and attestations. We plan reporting accordingly, but formal compliance assessment is separate.
- Scanner disagreement: tools use different databases and may report different counts. Do not chase parity; pick one source of truth.
- Cost of Snyk or similar: per-developer or per-project licensing adds up, so evaluate against what you will actually use.
Common failure modes
- Failing builds on every CVE, then adding
exit-code: 0everywhere. - Scanning only at build, never again.
- Ignore lists with no expiry.
- Huge images with full OS toolchains, producing endless noise.
- Nobody assigned to the findings queue.
Delivery and how to tell it works
You get scanning wired into CI, registry and cluster, a written triage policy, base image recommendations, dashboards of open findings by team, and alerts for new criticals in running workloads. It works when the count of fixable high findings trends down, builds fail rarely and for good reason, and you can answer a headline CVE question about your estate in minutes. To plan this for your stack, contact us.