imagecache

package
v1.6.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Overview

Package imagecache rewrites image references so the nodes pull them through the platform's in-cluster pull-through cache (zot with on-demand sync).

The cache is served on every node as localhost:<port> by the node-agent's registry forwarder. A reference REG/repo:tag becomes localhost:<port>/REG/repo:tag; the cache maps the REG prefix back to the upstream registry, so the layout needs no per-image configuration.

Index

Constants

This section is empty.

Variables

View Source
var DefaultRegistries = []string{"docker.io", "ghcr.io", "quay.io", "registry.k8s.io"}

DefaultRegistries are the upstream registries the chart configures by default.

Functions

func DigestOf

func DigestOf(ref string) string

DigestOf returns the digest of a reference that already names one, "" if not.

func ProbeDigest added in v1.2.0

func ProbeDigest(ctx context.Context, ref string, kc authn.Keychain, rt http.RoundTripper) (string, error)

ProbeDigest asks the registry (never a cache) for the manifest of ref, a tag or a digest, with the keychain over transport (nil: the default), and returns the digest it answers with. Unlike RegistryResolver.Resolve it contacts the registry for a digest reference too.

Types

type DockerConfigKeychain

type DockerConfigKeychain struct {
	// contains filtered or unexported fields
}

DockerConfigKeychain is a keychain over dockerconfigjson documents (the data of kubernetes.io/dockerconfigjson pull Secrets).

func NewDockerConfigKeychain

func NewDockerConfigKeychain(docs ...[]byte) (*DockerConfigKeychain, error)

NewDockerConfigKeychain parses dockerconfigjson documents; a malformed one is an error.

func (*DockerConfigKeychain) Has added in v1.2.0

func (k *DockerConfigKeychain) Has(host string) bool

Has says whether the keychain holds a login for the registry host, with the same normalization Resolve uses (docker.io, index.docker.io and URL forms are one registry).

func (*DockerConfigKeychain) Resolve

Resolve implements authn.Keychain.

type RegistryResolver

type RegistryResolver struct {
	Keychain authn.Keychain
	TTL      time.Duration
	// Timeout bounds one request; 15s when zero.
	Timeout time.Duration
	// Now is the clock; nil means time.Now.
	Now func() time.Time
	// Platforms lists the platforms of the nodes the images run on. With exactly
	// one, a multi-platform image is pinned to the manifest of that platform, so the
	// cache fetches that one image and not every architecture of the index. With
	// several (or none known) the index digest is pinned.
	Platforms func(ctx context.Context) []v1.Platform
	// contains filtered or unexported fields
}

RegistryResolver resolves tags with a HEAD request to the upstream registry (never through the cache, which would answer with what it has stored). Answers are remembered for TTL, so labs created in the same wave, and the prepull, see one digest even when the upstream tag moves meanwhile.

func (*RegistryResolver) Resolve

func (r *RegistryResolver) Resolve(ctx context.Context, ref string) (string, error)

Resolve implements Resolver.

type Resolver

type Resolver interface {
	Resolve(ctx context.Context, ref string) (digest string, err error)
}

Resolver turns an image reference into the digest its tag points at now.

type Rewriter

type Rewriter struct {
	// Prefix is host:port of the cache as the nodes see it, e.g. "localhost:5035".
	Prefix string
	// Registries are the upstream registries the cache serves (docker.io, ghcr.io, ...).
	Registries []string
}

Rewriter rewrites image references for one cache.

func (Rewriter) RepoOf

func (r Rewriter) RepoOf(ref string) string

RepoOf returns the cache repository path of a reference that points at the cache (prefix stripped, tag or digest removed), "" if it does not.

func (Rewriter) Rewrite

func (r Rewriter) Rewrite(ref string) string

Rewrite returns the reference to pull through the cache. It returns ref unchanged when the rewriter is empty, the reference is malformed, it already points at the cache, or its registry is not one the cache serves (a private registry, or a snapshot image that is already local).

A reference without a registry is docker.io; one without a repository namespace gets "library/"; one without a tag gets ":latest" (Kubernetes treats the two alike). A reference with a digest keeps only the digest.

func (Rewriter) RewritePinned

func (r Rewriter) RewritePinned(ref, digest string) string

RewritePinned is Rewrite for a reference pinned to digest: the tag is replaced by the digest, so every pod of a lab pulls the very same image. A reference the cache does not serve is returned unchanged.

Jump to

Keyboard shortcuts

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