Skip to content

lib: introduce github.com/google/cadvisor/lib — a lean, kubelet-focused library module#3895

Merged
dims merged 5 commits into
google:masterfrom
dims:lib-module-split
Jun 20, 2026
Merged

lib: introduce github.com/google/cadvisor/lib — a lean, kubelet-focused library module#3895
dims merged 5 commits into
google:masterfrom
dims:lib-module-split

Conversation

@dims

@dims dims commented Jun 19, 2026

Copy link
Copy Markdown
Collaborator

This introduces github.com/google/cadvisor/lib, a lean library submodule containing the
kubelet-facing subset of cAdvisor, while keeping the standalone cAdvisor binary and its v1/v2
REST API fully working. The goal: let the kubelet (and other library consumers) depend on a
small, stable cAdvisor library directly, instead of importing the full module — and its
binary-only dependency surface — or carrying an out-of-tree fork.

The kubelet embeds cAdvisor for machine info, per-container stats, and the /metrics/cadvisor
series. Today it imports the full github.com/google/cadvisor module, which pulls in the
binary's dependency surface (HTTP server + web UI, the storage drivers, the standalone
prometheus client, perf/resctrl/NVM, cloud-provider probes, …). That bloats the kubelet's
module graph and couples it to code it never runs. A lean, explicitly kubelet-scoped library
module lets the kubelet depend only on what it uses.

@dims dims force-pushed the lib-module-split branch 5 times, most recently from 7252441 to 82de42e Compare June 20, 2026 20:11
dims added 5 commits June 20, 2026 16:20
…ry module

A subdirectory module holding the kubelet-only surface of cAdvisor (manager,
container, fs, cache, machine, metrics, storage, stats, watcher, cadvisorflags,
and lib/model). The manager exposes injection seams that the full binary fills
in and the kubelet leaves nil, so the library stays lean.

lib/model merges the leaf types of info/v1 and info/v2. Both named a filesystem
type FsInfo (machine-level vs runtime); since they now share one package, the
runtime type keeps the name FsInfo and the machine-level one is FilesystemInfo.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
root and cmd require+replace github.com/google/cadvisor/lib => ./lib (and
../lib). build.sh stamps version symbols in lib/version; the Makefile and
check_gotidy.sh run tests/lint/tidy over the lib module too.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
info/v1 becomes thin aliases to lib/model plus the v1 consts and docker types.
info/v2 aliases the identical leaf types and keeps its own ContainerInfo,
ContainerStats and Spec, plus the from-v1 converters the REST handlers use.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
Redirect moved-package imports to github.com/google/cadvisor/lib/* and delete
the duplicated root copies. The storage-driver registry consolidates into
lib/storage -- root and lib both registered the storage_driver_* flags, which
would double-register. The remaining root packages (collector, events, perf,
resctrl, summary, validate, client, ...) adapt to the library.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
cmd builds the cAdvisor binary and v1/v2 REST API against lib, registering the
perf/resctrl factories, summary reader, process-list and app-metrics providers,
the cpu-load reader, and the events.EventManager (via the library's EventSink)
into the manager's seams.

Signed-off-by: Davanum Srinivas <davanum@gmail.com>
@dims dims force-pushed the lib-module-split branch from 82de42e to 4f46da3 Compare June 20, 2026 20:21
@dims dims changed the title [WIP] lib: introduce github.com/google/cadvisor/lib — a lean, kubelet-focused library module Jun 20, 2026
@dims dims merged commit eb7a559 into google:master Jun 20, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant