Documentation ¶
Overview ¶
Package cruntime contains code specific to container runtimes
Index ¶
- Constants
- Variables
- func AddDockerIO(name string) string
- func AddLocalhostPrefix(name string) string
- func CheckCompatibility(cr Manager) error
- func CheckKernelCompatibility(cr CommandRunner, major, minor int) error
- func ContainerStatusCommand() string
- func ValidRuntimes() []string
- type CRIO
- func (r *CRIO) Active() bool
- func (r *CRIO) Available() error
- func (r *CRIO) BuildImage(src string, file string, tag string, push bool, env []string, opts []string) error
- func (r *CRIO) CGroupDriver() (string, error)
- func (r *CRIO) ContainerLogCmd(id string, len int, follow bool) string
- func (r *CRIO) Disable() error
- func (r *CRIO) Enable(disOthers bool, cgroupDriver string, inUserNamespace bool) error
- func (r *CRIO) ImageExists(name string, sha string) bool
- func (r *CRIO) ImagesPreloaded(images []string) bool
- func (r *CRIO) KillContainers(ids []string) error
- func (r *CRIO) KubeletOptions() map[string]string
- func (r *CRIO) ListContainers(o ListContainersOptions) ([]string, error)
- func (r *CRIO) ListImages(ListImagesOptions) ([]ListImage, error)
- func (r *CRIO) LoadImage(path string) error
- func (r *CRIO) Name() string
- func (r *CRIO) PauseContainers(ids []string) error
- func (r *CRIO) Preload(cc config.ClusterConfig) error
- func (r *CRIO) PullImage(name string) error
- func (r *CRIO) PushImage(name string) error
- func (r *CRIO) RemoveImage(name string) error
- func (r *CRIO) SaveImage(name string, path string) error
- func (r *CRIO) SocketPath() string
- func (r *CRIO) StopContainers(ids []string) error
- func (r *CRIO) Style() style.Enum
- func (r *CRIO) SystemLogCmd(len int) string
- func (r *CRIO) TagImage(source string, target string) error
- func (r *CRIO) UnpauseContainers(ids []string) error
- func (r *CRIO) Version() (string, error)
- type CommandRunner
- type Config
- type ContainerState
- type Containerd
- func (r *Containerd) Active() bool
- func (r *Containerd) Available() error
- func (r *Containerd) BuildImage(src string, file string, tag string, push bool, env []string, opts []string) error
- func (r *Containerd) CGroupDriver() (string, error)
- func (r *Containerd) ContainerLogCmd(id string, len int, follow bool) string
- func (r *Containerd) Disable() error
- func (r *Containerd) Enable(disOthers bool, cgroupDriver string, inUserNamespace bool) error
- func (r *Containerd) ImageExists(name string, sha string) bool
- func (r *Containerd) ImagesPreloaded(images []string) bool
- func (r *Containerd) KillContainers(ids []string) error
- func (r *Containerd) KubeletOptions() map[string]string
- func (r *Containerd) ListContainers(o ListContainersOptions) ([]string, error)
- func (r *Containerd) ListImages(ListImagesOptions) ([]ListImage, error)
- func (r *Containerd) LoadImage(path string) error
- func (r *Containerd) Name() string
- func (r *Containerd) PauseContainers(ids []string) error
- func (r *Containerd) Preload(cc config.ClusterConfig) error
- func (r *Containerd) PullImage(name string) error
- func (r *Containerd) PushImage(name string) error
- func (r *Containerd) RemoveImage(name string) error
- func (r *Containerd) Restart() error
- func (r *Containerd) SaveImage(name string, path string) error
- func (r *Containerd) SocketPath() string
- func (r *Containerd) StopContainers(ids []string) error
- func (r *Containerd) Style() style.Enum
- func (r *Containerd) SystemLogCmd(len int) string
- func (r *Containerd) TagImage(source string, target string) error
- func (r *Containerd) UnpauseContainers(ids []string) error
- func (r *Containerd) Version() (string, error)
- type Docker
- func (r *Docker) Active() bool
- func (r *Docker) Available() error
- func (r *Docker) BuildImage(src string, file string, tag string, push bool, env []string, opts []string) error
- func (r *Docker) CGroupDriver() (string, error)
- func (r *Docker) ContainerLogCmd(id string, len int, follow bool) string
- func (r *Docker) Disable() error
- func (r *Docker) Enable(disOthers bool, cgroupDriver string, inUserNamespace bool) error
- func (r *Docker) ImageExists(name string, sha string) bool
- func (r *Docker) ImagesPreloaded(images []string) bool
- func (r *Docker) KillContainers(ids []string) error
- func (r *Docker) KubeletOptions() map[string]string
- func (r *Docker) ListContainers(o ListContainersOptions) ([]string, error)
- func (r *Docker) ListImages(ListImagesOptions) ([]ListImage, error)
- func (r *Docker) LoadImage(path string) error
- func (r *Docker) Name() string
- func (r *Docker) PauseContainers(ids []string) error
- func (r *Docker) Preload(cc config.ClusterConfig) error
- func (r *Docker) PullImage(name string) error
- func (r *Docker) PushImage(name string) error
- func (r *Docker) RemoveImage(name string) error
- func (r *Docker) Restart() error
- func (r *Docker) SaveImage(name string, path string) error
- func (r *Docker) SocketPath() string
- func (r *Docker) StopContainers(ids []string) error
- func (r *Docker) Style() style.Enum
- func (r *Docker) SystemLogCmd(len int) string
- func (r *Docker) TagImage(source string, target string) error
- func (r *Docker) UnpauseContainers(ids []string) error
- func (r *Docker) Version() (string, error)
- type ErrISOFeature
- type ErrServiceVersion
- type ListContainersOptions
- type ListImage
- type ListImagesOptions
- type Manager
Constants ¶
const ( CNIBinDir = "/opt/cni/bin" CNICacheDir = "/var/lib/cni/cache" )
const ExternalDockerCRISocket = "/var/run/cri-dockerd.sock"
const InternalDockerCRISocket = "/var/run/dockershim.sock"
const KubernetesContainerPrefix = "k8s_"
KubernetesContainerPrefix is the prefix of each Kubernetes container
Variables ¶
var ErrContainerRuntimeNotRunning = errors.New("container runtime is not running")
ErrContainerRuntimeNotRunning is thrown when container runtime is not running
Functions ¶
func AddLocalhostPrefix ¶ added in v1.34.0
Add localhost prefix if the registry part is missing
func CheckCompatibility ¶ added in v1.22.0
CheckCompatibility checks if the container runtime managed by "cr" is compatible with current minikube code returns: NewErrServiceVersion if not
func CheckKernelCompatibility ¶ added in v1.26.0
func CheckKernelCompatibility(cr CommandRunner, major, minor int) error
CheckKernelCompatibility returns an error when the kernel is older than the specified version.
func ContainerStatusCommand ¶ added in v1.7.0
func ContainerStatusCommand() string
ContainerStatusCommand works across container runtimes with good formatting
func ValidRuntimes ¶ added in v1.12.0
func ValidRuntimes() []string
ValidRuntimes lists the supported container runtimes
Types ¶
type CRIO ¶
type CRIO struct { Socket string Runner CommandRunner ImageRepository string KubernetesVersion semver.Version Init sysinit.Manager }
CRIO contains CRIO runtime state
func (*CRIO) Available ¶
Available returns an error if it is not possible to use this runtime on a host
func (*CRIO) BuildImage ¶ added in v1.20.0
func (r *CRIO) BuildImage(src string, file string, tag string, push bool, env []string, opts []string) error
BuildImage builds an image into this runtime
func (*CRIO) CGroupDriver ¶ added in v1.7.0
CGroupDriver returns cgroup driver ("cgroupfs" or "systemd")
func (*CRIO) ContainerLogCmd ¶
ContainerLogCmd returns the command to retrieve the log for a container based on ID
func (*CRIO) ImageExists ¶ added in v1.6.0
ImageExists checks if image exists based on image name and optionally image sha
func (*CRIO) ImagesPreloaded ¶ added in v1.12.3
ImagesPreloaded returns true if all images have been preloaded
func (*CRIO) KillContainers ¶
KillContainers removes containers based on ID
func (*CRIO) KubeletOptions ¶
KubeletOptions returns kubelet options for a runtime.
func (*CRIO) ListContainers ¶
func (r *CRIO) ListContainers(o ListContainersOptions) ([]string, error)
ListContainers returns a list of managed by this container runtime
func (*CRIO) ListImages ¶ added in v1.19.0
func (r *CRIO) ListImages(ListImagesOptions) ([]ListImage, error)
ListImages returns a list of images managed by this container runtime
func (*CRIO) PauseContainers ¶ added in v1.7.0
PauseContainers pauses a running container based on ID
func (*CRIO) Preload ¶ added in v1.8.0
func (r *CRIO) Preload(cc config.ClusterConfig) error
Preload preloads the container runtime with k8s images
func (*CRIO) RemoveImage ¶ added in v1.19.0
RemoveImage removes a image
func (*CRIO) SocketPath ¶
SocketPath returns the path to the socket file for CRIO
func (*CRIO) StopContainers ¶
StopContainers stops containers based on ID
func (*CRIO) SystemLogCmd ¶ added in v1.3.0
SystemLogCmd returns the command to retrieve system logs
func (*CRIO) UnpauseContainers ¶ added in v1.7.0
UnpauseContainers unpauses a running container based on ID
type CommandRunner ¶
type CommandRunner interface { // RunCmd is a blocking method that runs a command // Use this if you don't need to stream stdout and stderr in real-time RunCmd(cmd *exec.Cmd) (*command.RunResult, error) // StartCmd is a non-blocking method that starts a command // Use WaitCmd to block until the command is complete // Use this if you need to stream stdout and/or stderr in real-time StartCmd(cmd *exec.Cmd) (*command.StartedCmd, error) // WaitCmd blocks until the started command completes WaitCmd(sc *command.StartedCmd) (*command.RunResult, error) // Copy is a convenience method that runs a command to copy a file Copy(assets.CopyableFile) error // CopyFrom is a convenience method that runs a command to copy a file back CopyFrom(assets.CopyableFile) error // Remove is a convenience method that runs a command to remove a file Remove(assets.CopyableFile) error ReadableFile(sourcePath string) (assets.ReadableFile, error) }
CommandRunner is the subset of command.Runner this package consumes
type Config ¶
type Config struct { // Type of runtime to create ("docker, "crio", etc) Type string // Custom path to a socket file Socket string // Runner is the CommandRunner object to execute commands with Runner CommandRunner // NetworkPlugin name of networking plugin ("cni") NetworkPlugin string // ImageRepository image repository to download image from ImageRepository string // KubernetesVersion Kubernetes version KubernetesVersion semver.Version // InsecureRegistry list of insecure registries InsecureRegistry []string // GPUs add GPU devices to the container GPUs bool }
Config is runtime configuration
type ContainerState ¶ added in v1.7.0
type ContainerState int
ContainerState is the run state of a container
const ( // All is all of the states All ContainerState = iota // Running is only running Running // Paused is only paused Paused )
func (ContainerState) String ¶ added in v1.7.0
func (cs ContainerState) String() string
type Containerd ¶
type Containerd struct { Socket string Runner CommandRunner ImageRepository string KubernetesVersion semver.Version Init sysinit.Manager InsecureRegistry []string }
Containerd contains containerd runtime state
func (*Containerd) Active ¶
func (r *Containerd) Active() bool
Active returns if containerd is active on the host
func (*Containerd) Available ¶
func (r *Containerd) Available() error
Available returns an error if it is not possible to use this runtime on a host
func (*Containerd) BuildImage ¶ added in v1.20.0
func (r *Containerd) BuildImage(src string, file string, tag string, push bool, env []string, opts []string) error
BuildImage builds an image into this runtime
func (*Containerd) CGroupDriver ¶ added in v1.7.0
func (r *Containerd) CGroupDriver() (string, error)
CGroupDriver returns cgroup driver ("cgroupfs" or "systemd")
func (*Containerd) ContainerLogCmd ¶
func (r *Containerd) ContainerLogCmd(id string, len int, follow bool) string
ContainerLogCmd returns the command to retrieve the log for a container based on ID
func (*Containerd) Disable ¶
func (r *Containerd) Disable() error
Disable idempotently disables containerd on a host
func (*Containerd) Enable ¶
func (r *Containerd) Enable(disOthers bool, cgroupDriver string, inUserNamespace bool) error
Enable idempotently enables containerd on a host It is also called by docker.Enable() - if bound to containerd, to enforce proper containerd configuration completed by service restart.
func (*Containerd) ImageExists ¶ added in v1.6.0
func (r *Containerd) ImageExists(name string, sha string) bool
ImageExists checks if image exists based on image name and optionally image sha
func (*Containerd) ImagesPreloaded ¶ added in v1.12.3
func (r *Containerd) ImagesPreloaded(images []string) bool
ImagesPreloaded returns true if all images have been preloaded
func (*Containerd) KillContainers ¶
func (r *Containerd) KillContainers(ids []string) error
KillContainers removes containers based on ID
func (*Containerd) KubeletOptions ¶
func (r *Containerd) KubeletOptions() map[string]string
KubeletOptions returns kubelet options for a containerd
func (*Containerd) ListContainers ¶
func (r *Containerd) ListContainers(o ListContainersOptions) ([]string, error)
ListContainers returns a list of managed by this container runtime
func (*Containerd) ListImages ¶ added in v1.19.0
func (r *Containerd) ListImages(ListImagesOptions) ([]ListImage, error)
ListImages lists images managed by this container runtime
func (*Containerd) LoadImage ¶
func (r *Containerd) LoadImage(path string) error
LoadImage loads an image into this runtime
func (*Containerd) Name ¶
func (r *Containerd) Name() string
Name is a human readable name for containerd
func (*Containerd) PauseContainers ¶ added in v1.7.0
func (r *Containerd) PauseContainers(ids []string) error
PauseContainers pauses a running container based on ID
func (*Containerd) Preload ¶ added in v1.8.0
func (r *Containerd) Preload(cc config.ClusterConfig) error
Preload preloads the container runtime with k8s images
func (*Containerd) PullImage ¶ added in v1.20.0
func (r *Containerd) PullImage(name string) error
PullImage pulls an image into this runtime
func (*Containerd) PushImage ¶ added in v1.23.0
func (r *Containerd) PushImage(name string) error
PushImage pushes an image
func (*Containerd) RemoveImage ¶ added in v1.19.0
func (r *Containerd) RemoveImage(name string) error
RemoveImage removes a image
func (*Containerd) Restart ¶ added in v1.10.0
func (r *Containerd) Restart() error
Restart restarts this container runtime on a host
func (*Containerd) SaveImage ¶ added in v1.20.0
func (r *Containerd) SaveImage(name string, path string) error
SaveImage save an image from this runtime
func (*Containerd) SocketPath ¶
func (r *Containerd) SocketPath() string
SocketPath returns the path to the socket file for containerd
func (*Containerd) StopContainers ¶
func (r *Containerd) StopContainers(ids []string) error
StopContainers stops containers based on ID
func (*Containerd) Style ¶ added in v1.1.1
func (r *Containerd) Style() style.Enum
Style is the console style for containerd
func (*Containerd) SystemLogCmd ¶ added in v1.3.0
func (r *Containerd) SystemLogCmd(len int) string
SystemLogCmd returns the command to retrieve system logs
func (*Containerd) TagImage ¶ added in v1.23.0
func (r *Containerd) TagImage(source string, target string) error
TagImage tags an image in this runtime
func (*Containerd) UnpauseContainers ¶ added in v1.7.0
func (r *Containerd) UnpauseContainers(ids []string) error
UnpauseContainers unpauses a running container based on ID
func (*Containerd) Version ¶ added in v1.0.0
func (r *Containerd) Version() (string, error)
Version retrieves the current version of this runtime
type Docker ¶
type Docker struct { Socket string Runner CommandRunner NetworkPlugin string ImageRepository string KubernetesVersion semver.Version Init sysinit.Manager UseCRI bool CRIService string GPUs bool }
Docker contains Docker runtime state
func (*Docker) Available ¶
Available returns an error if it is not possible to use this runtime on a host
func (*Docker) BuildImage ¶ added in v1.20.0
func (r *Docker) BuildImage(src string, file string, tag string, push bool, env []string, opts []string) error
BuildImage builds an image into this runtime
func (*Docker) CGroupDriver ¶ added in v1.7.0
CGroupDriver returns cgroup driver ("cgroupfs" or "systemd")
func (*Docker) ContainerLogCmd ¶
ContainerLogCmd returns the command to retrieve the log for a container based on ID
func (*Docker) ImageExists ¶ added in v1.6.0
ImageExists checks if image exists based on image name and optionally image sha
func (*Docker) ImagesPreloaded ¶ added in v1.12.3
ImagesPreloaded returns true if all images have been preloaded
func (*Docker) KillContainers ¶
KillContainers forcibly removes a running container based on ID
func (*Docker) KubeletOptions ¶
KubeletOptions returns kubelet options for a runtime.
func (*Docker) ListContainers ¶
func (r *Docker) ListContainers(o ListContainersOptions) ([]string, error)
ListContainers returns a list of containers
func (*Docker) ListImages ¶ added in v1.19.0
func (r *Docker) ListImages(ListImagesOptions) ([]ListImage, error)
ListImages returns a list of images managed by this container runtime
func (*Docker) PauseContainers ¶ added in v1.7.0
PauseContainers pauses a running container based on ID
func (*Docker) Preload ¶ added in v1.8.0
func (r *Docker) Preload(cc config.ClusterConfig) error
Preload preloads docker with k8s images: 1. Copy over the preloaded tarball into the VM 2. Extract the preloaded tarball to the correct directory 3. Remove the tarball within the VM
func (*Docker) RemoveImage ¶ added in v1.19.0
RemoveImage removes a image
func (*Docker) SocketPath ¶
SocketPath returns the path to the socket file for Docker
func (*Docker) StopContainers ¶
StopContainers stops a running container based on ID
func (*Docker) SystemLogCmd ¶ added in v1.3.0
SystemLogCmd returns the command to retrieve system logs
func (*Docker) UnpauseContainers ¶ added in v1.7.0
UnpauseContainers unpauses a container based on ID
type ErrISOFeature ¶ added in v1.8.2
type ErrISOFeature struct {
// contains filtered or unexported fields
}
ErrISOFeature is the error returned when disk image is missing features
func NewErrISOFeature ¶ added in v1.8.2
func NewErrISOFeature(missing string) *ErrISOFeature
NewErrISOFeature creates a new ErrISOFeature
func (*ErrISOFeature) Error ¶ added in v1.8.2
func (e *ErrISOFeature) Error() string
type ErrServiceVersion ¶ added in v1.22.0
type ErrServiceVersion struct { // Service is the name of the incompatible service Service string // Installed is the installed version of Service Installed string // Required is the minimum required version of Service Required string }
ErrServiceVersion is the error returned when disk image has incompatible version of service
func NewErrServiceVersion ¶ added in v1.22.0
func NewErrServiceVersion(svc, required, installed string) *ErrServiceVersion
NewErrServiceVersion creates a new ErrServiceVersion
func (ErrServiceVersion) Error ¶ added in v1.22.0
func (e ErrServiceVersion) Error() string
type ListContainersOptions ¶ added in v1.19.0
type ListContainersOptions struct { // State is the container state to filter by (All, Running, Paused) State ContainerState // Name is a name filter Name string // Namespaces is the namespaces to look into Namespaces []string }
ListContainersOptions are the options to use for listing containers
type ListImagesOptions ¶ added in v1.19.0
type ListImagesOptions struct { }
ListImagesOptions are the options to use for listing images
type Manager ¶
type Manager interface { // Name is a human readable name for a runtime Name() string // Version retrieves the current version of this runtime Version() (string, error) // Enable idempotently enables this runtime on a host Enable(bool, string, bool) error // Disable idempotently disables this runtime on a host Disable() error // Active returns whether or not a runtime is active on a host Active() bool // Available returns an error if it is not possible to use this runtime on a host Available() error // Style is an associated StyleEnum for Name() Style() style.Enum // CGroupDriver returns cgroup driver ("cgroupfs" or "systemd") CGroupDriver() (string, error) // KubeletOptions returns kubelet options for a runtime. KubeletOptions() map[string]string // SocketPath returns the path to the socket file for a given runtime SocketPath() string // Load an image idempotently into the runtime on a host LoadImage(string) error // Pull an image to the runtime from the container registry PullImage(string) error // Build an image idempotently into the runtime on a host BuildImage(string, string, string, bool, []string, []string) error // Save an image from the runtime on a host SaveImage(string, string) error // Tag an image TagImage(string, string) error // Push an image from the runtime to the container registry PushImage(string) error // ImageExists takes image name and optionally image sha to check if an image exists ImageExists(string, string) bool // ListImages returns a list of images managed by this container runtime ListImages(ListImagesOptions) ([]ListImage, error) // RemoveImage remove image based on name RemoveImage(string) error // ListContainers returns a list of containers managed by this container runtime ListContainers(ListContainersOptions) ([]string, error) // KillContainers removes containers based on ID KillContainers([]string) error // StopContainers stops containers based on ID StopContainers([]string) error // PauseContainers pauses containers based on ID PauseContainers([]string) error // UnpauseContainers unpauses containers based on ID UnpauseContainers([]string) error // ContainerLogCmd returns the command to retrieve the log for a container based on ID ContainerLogCmd(string, int, bool) string // SystemLogCmd returns the command to return the system logs SystemLogCmd(int) string // Preload preloads the container runtime with k8s images Preload(config.ClusterConfig) error // ImagesPreloaded returns true if all images have been preloaded ImagesPreloaded([]string) bool }
Manager is a common interface for container runtimes