image

package
v5.22.0 Latest Latest
Warning

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

Go to latest
Published: Jan 24, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package image provides services for exporting and importing container images to and from Kubernetes cluster containerd runtimes.

This package supports the following Kubernetes distributions:

  • Vanilla (Kind): Uses Docker exec to run ctr commands in Kind nodes
  • K3s (K3d): Uses Docker exec to run ctr commands in K3d nodes

Note: Talos distribution is NOT supported for image export/import operations. Talos is an immutable OS without shell access, and its Machine API does not expose image export functionality. Only ImageList and ImagePull APIs are available.

All operations use Go libraries only (Docker SDK) and do not rely on any binaries installed on the host machine.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ErrExecFailed is returned when a container exec command fails.
	ErrExecFailed = errors.New("container exec failed")
	// ErrInvalidClusterName is returned when a cluster name cannot be determined from context.
	ErrInvalidClusterName = errors.New("unable to determine cluster name from context")
	// ErrFileNotFoundInArchive is returned when an expected file is not found in a tar archive.
	ErrFileNotFoundInArchive = errors.New("file not found in tar archive")
	// ErrNoK8sNodesFound is returned when no valid Kubernetes nodes are found.
	ErrNoK8sNodesFound = errors.New("no valid kubernetes nodes found for image operations")
	// ErrInputFileNotFound is returned when the input file does not exist.
	ErrInputFileNotFound = errors.New("input file does not exist")
	// ErrUnsupportedDistribution is returned when the distribution does not support image operations.
	ErrUnsupportedDistribution = errors.New(
		"talos does not support image export/import (immutable OS without shell access)",
	)
)

Sentinel errors for the image package.

View Source
var (
	// ErrNoNodes is returned when no cluster nodes are found.
	ErrNoNodes = errors.New("no cluster nodes found")
	// ErrUnsupportedProvider is returned when the provider is not supported for image operations.
	ErrUnsupportedProvider = errors.New("unsupported provider for image operations")
	// ErrNoImagesFound is returned when no images are found in the cluster.
	ErrNoImagesFound = errors.New("no images found in cluster")
)

Error definitions.

Functions

This section is empty.

Types

type ContainerExecutor

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

ContainerExecutor provides methods for executing commands in containers.

func NewContainerExecutor

func NewContainerExecutor(dockerClient client.APIClient) *ContainerExecutor

NewContainerExecutor creates a new container executor.

func (*ContainerExecutor) ExecInContainer

func (e *ContainerExecutor) ExecInContainer(
	ctx context.Context,
	containerName string,
	cmd []string,
) (string, error)

ExecInContainer executes a command inside a container and returns stdout.

type ExportOptions

type ExportOptions struct {
	// OutputPath is the file path for the exported tar archive.
	// Defaults to "images.tar" in the current directory.
	OutputPath string
	// Images is an optional list of specific images to export.
	// If empty, all images in the cluster will be exported.
	Images []string
}

ExportOptions configures the image export operation.

type Exporter

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

Exporter handles exporting container images from cluster containerd.

func NewExporter

func NewExporter(dockerClient client.APIClient) *Exporter

NewExporter creates a new image exporter.

func (*Exporter) Export

func (e *Exporter) Export(
	ctx context.Context,
	clusterName string,
	distribution v1alpha1.Distribution,
	providerType v1alpha1.Provider,
	opts ExportOptions,
) error

Export exports container images from the cluster's containerd runtime.

type ImportOptions

type ImportOptions struct {
	// InputPath is the file path of the tar archive to import.
	// Defaults to "images.tar" in the current directory.
	InputPath string
}

ImportOptions configures the image import operation.

type Importer

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

Importer handles importing container images to cluster containerd.

func NewImporter

func NewImporter(dockerClient client.APIClient) *Importer

NewImporter creates a new image importer.

func (*Importer) Import

func (i *Importer) Import(
	ctx context.Context,
	clusterName string,
	distribution v1alpha1.Distribution,
	providerType v1alpha1.Provider,
	opts ImportOptions,
) error

Import imports container images to the cluster's containerd runtime.

Jump to

Keyboard shortcuts

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