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 ¶
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.
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 ¶
NewExporter creates a new image exporter.
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 ¶
NewImporter creates a new image importer.