cadvisor

package
v1.36.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 11, 2026 License: Apache-2.0 Imports: 34 Imported by: 562

Documentation

Overview

Package cadvisor provides an interface for Kubelet interactions with cAdvisor.

Index

Constants

View Source
const (
	// CrioSocketSuffix is the path to the CRI-O socket.
	// Please keep this in sync with the one in:
	// github.com/google/cadvisor/tree/master/container/crio/client.go
	// Note that however we only match on the suffix, as /var/run is often a
	// symlink to /run, so the user can specify either path.
	CrioSocketSuffix = "run/crio/crio.sock"
)

Variables

This section is empty.

Functions

func CapacityFromMachineInfo added in v1.2.0

func CapacityFromMachineInfo(info *cadvisorapi.MachineInfo) v1.ResourceList

CapacityFromMachineInfo returns the capacity of the resources from the machine info.

func EphemeralStorageCapacityFromFsInfo added in v1.8.0

func EphemeralStorageCapacityFromFsInfo(info cadvisorapi2.FsInfo) v1.ResourceList

EphemeralStorageCapacityFromFsInfo returns the capacity of the ephemeral storage from the FsInfo.

func IsPsiEnabled added in v1.36.0

func IsPsiEnabled(logger klog.Logger) bool

IsPsiEnabled checks whether PSI (Pressure Stall Information) is available on the host by opening the root cgroup's cpu.pressure file using the same opencontainers/cgroups library that cAdvisor uses to read actual PSI values. PSI is a single kernel feature (CONFIG_PSI / boot param "psi=") so checking cpu.pressure alone is sufficient to determine support for all three resources (cpu, memory, io).

func UsingLegacyCadvisorStats added in v1.9.0

func UsingLegacyCadvisorStats(runtimeEndpoint string) bool

UsingLegacyCadvisorStats returns true if container stats are provided by cadvisor instead of through the CRI. CRI integrations should get container metrics via CRI. TODO: cri-o relies on cadvisor as a temporary workaround. The code should be removed. Related issue: https://github.com/kubernetes/kubernetes/issues/51798

Types

type ImageFsInfoProvider added in v1.8.0

type ImageFsInfoProvider interface {
	// ImageFsInfoLabel returns the label cAdvisor should use to find the filesystem holding container images.
	ImageFsInfoLabel() (string, error)
	// In split image filesystem this will be different from ImageFsInfoLabel
	ContainerFsInfoLabel() (string, error)
}

ImageFsInfoProvider informs cAdvisor how to find imagefs for container images.

func NewImageFsInfoProvider added in v1.8.0

func NewImageFsInfoProvider(runtimeEndpoint string) ImageFsInfoProvider

NewImageFsInfoProvider returns a provider for the specified runtime configuration.

type Interface

type Interface interface {
	Start() error
	ContainerInfoV2(name string, options cadvisorapiv2.RequestOptions) (map[string]cadvisorapiv2.ContainerInfo, error)
	GetRequestedContainersInfo(containerName string, options cadvisorapiv2.RequestOptions) (map[string]*cadvisorapi.ContainerInfo, error)
	MachineInfo() (*cadvisorapi.MachineInfo, error)

	VersionInfo() (*cadvisorapi.VersionInfo, error)

	// Returns usage information about the filesystem holding container images.
	ImagesFsInfo(context.Context) (cadvisorapiv2.FsInfo, error)

	// Returns usage information about the root filesystem.
	RootFsInfo() (cadvisorapiv2.FsInfo, error)

	// Returns usage information about the writeable layer.
	// KEP 4191 can separate the image filesystem
	ContainerFsInfo(context.Context) (cadvisorapiv2.FsInfo, error)

	// Get filesystem information for the filesystem that contains the given file.
	GetDirFsInfo(path string) (cadvisorapiv2.FsInfo, error)
}

Interface is an abstract interface for testability. It abstracts the interface to cAdvisor.

func New

func New(logger klog.Logger, imageFsInfoProvider ImageFsInfoProvider, rootPath string, cgroupRoots []string, usingLegacyStats, localStorageCapacityIsolation bool) (Interface, error)

New creates a new cAdvisor Interface for linux systems.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL