kubernetesk8s.io/kubernetes/pkg/kubelet/images Index | Files | Directories

package images

import "k8s.io/kubernetes/pkg/kubelet/images"

Package images is responsible for managing lifecycle of container images.

Index

Constants

const (
	ImageGarbageCollectedTotalReasonAge   = "age"
	ImageGarbageCollectedTotalReasonSpace = "space"
)

ImageGarbageCollectedTotalReason* specify the reason why an image was garbage collected in the `image_garbage_collected_total` metric.

Variables

var (
	// ErrImagePullBackOff - Container image pull failed, kubelet is backing off image pull
	ErrImagePullBackOff = errors.New("ImagePullBackOff")

	// ErrImageInspect - Unable to inspect image
	ErrImageInspect = errors.New("ImageInspectError")

	// ErrImagePull - General image pull error
	ErrImagePull = errors.New("ErrImagePull")

	// ErrImageNeverPull - Required Image is absent on host and PullPolicy is NeverPullImage
	ErrImageNeverPull = errors.New("ErrImageNeverPull")

	// ErrInvalidImageName - Unable to parse the image name.
	ErrInvalidImageName = errors.New("InvalidImageName")
)

Types

type ImageGCManager

type ImageGCManager interface {
	// Applies the garbage collection policy. Errors include being unable to free
	// enough space as per the garbage collection policy.
	GarbageCollect(ctx context.Context, beganGC time.Time) error

	// Start async garbage collection of images.
	Start()

	GetImageList() ([]container.Image, error)

	// Delete all unused images.
	DeleteUnusedImages(ctx context.Context) error
}

ImageGCManager is an interface for managing lifecycle of all images. Implementation is thread-safe.

func NewImageGCManager

func NewImageGCManager(runtime container.Runtime, statsProvider StatsProvider, postGCHooks []PostImageGCHook, recorder record.EventRecorder, nodeRef *v1.ObjectReference, policy ImageGCPolicy, tracerProvider trace.TracerProvider) (ImageGCManager, error)

NewImageGCManager instantiates a new ImageGCManager object.

type ImageGCPolicy

type ImageGCPolicy struct {
	// Any usage above this threshold will always trigger garbage collection.
	// This is the highest usage we will allow.
	HighThresholdPercent int

	// Any usage below this threshold will never trigger garbage collection.
	// This is the lowest threshold we will try to garbage collect to.
	LowThresholdPercent int

	// Minimum age at which an image can be garbage collected.
	MinAge time.Duration

	// Maximum age after which an image can be garbage collected, regardless of disk usage.
	// Currently gated by MaximumImageGCAge feature gate and Kubelet configuration.
	// If 0, the feature is disabled.
	MaxAge time.Duration
}

ImageGCPolicy is a policy for garbage collecting images. Policy defines an allowed band in which garbage collection will be run.

type ImageManager

type ImageManager interface {
	// EnsureImageExists ensures that image specified by `imgRef` exists.
	EnsureImageExists(ctx context.Context, objRef *v1.ObjectReference, pod *v1.Pod, imgRef string, pullSecrets []v1.Secret, podSandboxConfig *runtimeapi.PodSandboxConfig, podRuntimeHandler string, pullPolicy v1.PullPolicy) (string, string, error)
}

ImageManager provides an interface to manage the lifecycle of images. Implementations of this interface are expected to deal with pulling (downloading), managing, and deleting container images. Implementations are expected to abstract the underlying runtimes. Implementations are expected to be thread safe.

func NewImageManager

func NewImageManager(
	recorder record.EventRecorder,
	nodeKeyring credentialprovider.DockerKeyring,
	imageService kubecontainer.ImageService,
	imagePullManager pullmanager.ImagePullManager,
	imageBackOff *flowcontrol.Backoff,
	serialized bool,
	maxParallelImagePulls *int32,
	qps float32,
	burst int,
	podPullingTimeRecorder ImagePodPullingTimeRecorder,
) ImageManager

NewImageManager instantiates a new ImageManager object.

type ImagePodPullingTimeRecorder

type ImagePodPullingTimeRecorder interface {
	RecordImageStartedPulling(podUID types.UID)
	RecordImageFinishedPulling(podUID types.UID)
}

type PostImageGCHook

type PostImageGCHook func(remainingImages []string, gcStart time.Time)

PostImageGCHook allows external sources to react to GC collect events. `remainingImages` is a list of images that were left on the system after garbage collection finished.

type StatsProvider

type StatsProvider interface {
	// ImageFsStats returns the stats of the image filesystem.
	ImageFsStats(ctx context.Context) (*statsapi.FsStats, *statsapi.FsStats, error)
}

StatsProvider is an interface for fetching stats used during image garbage collection.

Source Files

doc.go helpers.go image_gc_manager.go image_manager.go puller.go types.go

Directories

PathSynopsis
pkg/kubelet/images/pullmanagerpullmanager package keeps the implementation of the image pull manager and image credential verification policies
Version
v1.33.0 (latest)
Published
Apr 23, 2025
Platform
linux/amd64
Imports
32 packages
Last checked
3 hours ago

Tools for package owners.