containerd

package
v0.0.0-...-370d4cf Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: AGPL-3.0 Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// CertsDDir is containerd's registry config_path (config v3). Each subdir is a
	// registry namespace (e.g. docker.io) holding a hosts.toml with its mirror
	// hosts. This replaces the deprecated inline registry.mirrors in config.toml,
	// which containerd 2.x ignores once config_path is set.
	CertsDDir = "/etc/containerd/certs.d"

	ParamRegistryName   = "registry"
	DefaultRegistryName = "docker.io"
)
View Source
const DefaultContainerdRootPath = "/var/lib/containerd"

DefaultContainerdRootPath is containerd's default data root, used by the upgrade disk-space precheck.

View Source
const (
	DefaultNamespace = "k8s.io"
)

Variables

View Source
var (
	ParamImageName = "image"
)

Functions

func DeleteImage

func DeleteImage(ctx *fiber.Ctx) error

func DeleteRegistryMirror

func DeleteRegistryMirror(ctx *fiber.Ctx) error

DeleteRegistryMirror removes a registry's mirror config (its certs.d subdir).

func EnsureRegistryMirror

func EnsureRegistryMirror(ctx context.Context, registry, endpoint string) (bool, error)

EnsureRegistryMirror ensures endpoint is configured as a mirror host for registry: if it is already present (in any position) the list is left unchanged; otherwise it is prepended as the highest-priority host. Returns updated=true if it changed.

func GetRegistryMirrors

func GetRegistryMirrors(ctx *fiber.Ctx) (map[string]Mirror, error)

GetRegistryMirrors returns all configured registry mirrors keyed by registry namespace (from every certs.d/<registry>/hosts.toml).

func ListImages

func ListImages(ctx *fiber.Ctx, registry string) ([]*criruntimev1.Image, error)

func NewCRIImageService

func NewCRIImageService() (criapi.ImageManagerService, error)

func NewCRIRuntimeService

func NewCRIRuntimeService() (criapi.RuntimeService, error)

func NewClient

func NewClient() (*containerd.Client, error)

func ReconcileMirrorEndpoint

func ReconcileMirrorEndpoint(ctx context.Context, registry, endpoint string, present bool) (bool, error)

ReconcileMirrorEndpoint reconciles a single mirror host for registry:

  • present=true: if endpoint is already in the list (any position) the list is left as-is; if absent it is prepended as the highest-priority host.
  • present=false: endpoint is removed, preserving the order of the rest.

Returns updated=true if the hosts.toml changed. Useful for runtime reconcilers that add/withdraw a single mirror endpoint.

Types

type Mirror

type Mirror struct {
	Endpoints []string `json:"endpoint" toml:"endpoint"`
}

Mirror lists the pull-through mirror endpoints for a registry. The JSON shape ({"endpoint": [...]}) matches the containerd CRI Mirror type used by the previous (config v2) olaresd interface, kept for API compatibility.

func GetRegistryMirror

func GetRegistryMirror(ctx *fiber.Ctx) (*Mirror, error)

GetRegistryMirror returns the mirror config for a single registry (defaulting to docker.io).

func UpdateRegistryMirror

func UpdateRegistryMirror(ctx *fiber.Ctx) (*Mirror, error)

UpdateRegistryMirror replaces the mirror host list for a registry. The request body is a Mirror ({"endpoint": [...]}), matching the previous interface.

type PruneImageResult

type PruneImageResult struct {
	Images []*criruntimev1.Image `json:"images"`
	Count  int                   `json:"count"`
	Size   uint64                `json:"size"`
}

func PruneImages

func PruneImages(ctx *fiber.Ctx) (*PruneImageResult, error)

type Registry

type Registry struct {
	Name       string   `json:"name"`
	Endpoints  []string `json:"endpoints"`
	ImageCount int      `json:"image_count"`
	ImageSize  uint64   `json:"image_size"`
}

Registry is a registry view merged from configured mirrors and locally cached images (used by the ListRegistries endpoint).

func ListRegistries

func ListRegistries(ctx *fiber.Ctx) ([]*Registry, error)

ListRegistries merges configured mirrors with registries discovered from locally cached images.

Jump to

Keyboard shortcuts

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