cruntime

package
v1.14.1 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2020 License: Apache-2.0 Imports: 22 Imported by: 24

Documentation

Overview

Package cruntime contains code specific to container runtimes

Index

Constants

View Source
const KubernetesContainerPrefix = "k8s_"

KubernetesContainerPrefix is the prefix of each Kubernetes container

Variables

This section is empty.

Functions

func ContainerStatusCommand added in v1.7.0

func ContainerStatusCommand() string

ContainerStatusCommand works across container runtimes with good formatting

func UpdateCRIONet added in v1.12.0

func UpdateCRIONet(r CommandRunner, cidr string) error

UpdateCRIONet updates CRIO CNI network configuration and restarts it

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) Active

func (r *CRIO) Active() bool

Active returns if CRIO is active on the host

func (*CRIO) Available

func (r *CRIO) Available() error

Available returns an error if it is not possible to use this runtime on a host

func (*CRIO) CGroupDriver added in v1.7.0

func (r *CRIO) CGroupDriver() (string, error)

CGroupDriver returns cgroup driver ("cgroupfs" or "systemd")

func (*CRIO) ContainerLogCmd

func (r *CRIO) ContainerLogCmd(id string, len int, follow bool) string

ContainerLogCmd returns the command to retrieve the log for a container based on ID

func (*CRIO) Disable

func (r *CRIO) Disable() error

Disable idempotently disables CRIO on a host

func (*CRIO) Enable

func (r *CRIO) Enable(disOthers, _ bool) error

Enable idempotently enables CRIO on a host

func (*CRIO) ImageExists added in v1.6.0

func (r *CRIO) ImageExists(name string, sha string) bool

ImageExists checks if an image exists

func (*CRIO) ImagesPreloaded added in v1.12.3

func (r *CRIO) ImagesPreloaded(images []string) bool

ImagesPreloaded returns true if all images have been preloaded

func (*CRIO) KillContainers

func (r *CRIO) KillContainers(ids []string) error

KillContainers removes containers based on ID

func (*CRIO) KubeletOptions

func (r *CRIO) KubeletOptions() map[string]string

KubeletOptions returns kubelet options for a runtime.

func (*CRIO) ListContainers

func (r *CRIO) ListContainers(o ListOptions) ([]string, error)

ListContainers returns a list of managed by this container runtime

func (*CRIO) LoadImage

func (r *CRIO) LoadImage(path string) error

LoadImage loads an image into this runtime

func (*CRIO) Name

func (r *CRIO) Name() string

Name is a human readable name for CRIO

func (*CRIO) PauseContainers added in v1.7.0

func (r *CRIO) PauseContainers(ids []string) error

PauseContainers pauses a running container based on ID

func (*CRIO) Preload added in v1.8.0

func (r *CRIO) Preload(cfg config.KubernetesConfig) error

Preload preloads the container runtime with k8s images

func (*CRIO) SocketPath

func (r *CRIO) SocketPath() string

SocketPath returns the path to the socket file for CRIO

func (*CRIO) StopContainers

func (r *CRIO) StopContainers(ids []string) error

StopContainers stops containers based on ID

func (*CRIO) Style added in v1.1.1

func (r *CRIO) Style() style.Enum

Style is the console style for CRIO

func (*CRIO) SystemLogCmd added in v1.3.0

func (r *CRIO) SystemLogCmd(len int) string

SystemLogCmd returns the command to retrieve system logs

func (*CRIO) UnpauseContainers added in v1.7.0

func (r *CRIO) UnpauseContainers(ids []string) error

UnpauseContainers unpauses a running container based on ID

func (*CRIO) Version added in v1.0.0

func (r *CRIO) Version() (string, error)

Version retrieves the current version of this runtime

type CommandRunner

type CommandRunner interface {
	RunCmd(cmd *exec.Cmd) (*command.RunResult, error)
	// Copy is a convenience method that runs a command to copy a file
	Copy(assets.CopyableFile) error
	// Remove is a convenience method that runs a command to remove a file
	Remove(assets.CopyableFile) 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
	// ImageRepository image repository to download image from
	ImageRepository string
	// KubernetesVersion Kubernetes version
	KubernetesVersion semver.Version
}

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
}

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) 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) error

Enable idempotently enables containerd on a host

func (*Containerd) ImageExists added in v1.6.0

func (r *Containerd) ImageExists(name string, sha string) bool

ImageExists checks if an image exists, expected input format

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 ListOptions) ([]string, error)

ListContainers returns a list of 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(cfg config.KubernetesConfig) error

Preload preloads the container runtime with k8s images

func (*Containerd) Restart added in v1.10.0

func (r *Containerd) Restart() error

Restart restarts Docker on a host

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) 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
	Init   sysinit.Manager
}

Docker contains Docker runtime state

func (*Docker) Active

func (r *Docker) Active() bool

Active returns if docker is active on the host

func (*Docker) Available

func (r *Docker) Available() error

Available returns an error if it is not possible to use this runtime on a host

func (*Docker) CGroupDriver added in v1.7.0

func (r *Docker) CGroupDriver() (string, error)

CGroupDriver returns cgroup driver ("cgroupfs" or "systemd")

func (*Docker) ContainerLogCmd

func (r *Docker) ContainerLogCmd(id string, len int, follow bool) string

ContainerLogCmd returns the command to retrieve the log for a container based on ID

func (*Docker) Disable

func (r *Docker) Disable() error

Disable idempotently disables Docker on a host

func (*Docker) Enable

func (r *Docker) Enable(disOthers, forceSystemd bool) error

Enable idempotently enables Docker on a host

func (*Docker) ImageExists added in v1.6.0

func (r *Docker) ImageExists(name string, sha string) bool

ImageExists checks if an image exists

func (*Docker) ImagesPreloaded added in v1.12.3

func (r *Docker) ImagesPreloaded(images []string) bool

ImagesPreloaded returns true if all images have been preloaded

func (*Docker) KillContainers

func (r *Docker) KillContainers(ids []string) error

KillContainers forcibly removes a running container based on ID

func (*Docker) KubeletOptions

func (r *Docker) KubeletOptions() map[string]string

KubeletOptions returns kubelet options for a runtime.

func (*Docker) ListContainers

func (r *Docker) ListContainers(o ListOptions) ([]string, error)

ListContainers returns a list of containers

func (*Docker) LoadImage

func (r *Docker) LoadImage(path string) error

LoadImage loads an image into this runtime

func (*Docker) Name

func (r *Docker) Name() string

Name is a human readable name for Docker

func (*Docker) PauseContainers added in v1.7.0

func (r *Docker) PauseContainers(ids []string) error

PauseContainers pauses a running container based on ID

func (*Docker) Preload added in v1.8.0

func (r *Docker) Preload(cfg config.KubernetesConfig) 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) Restart added in v1.8.0

func (r *Docker) Restart() error

Restart restarts Docker on a host

func (*Docker) SocketPath

func (r *Docker) SocketPath() string

SocketPath returns the path to the socket file for Docker

func (*Docker) StopContainers

func (r *Docker) StopContainers(ids []string) error

StopContainers stops a running container based on ID

func (*Docker) Style added in v1.1.1

func (r *Docker) Style() style.Enum

Style is the console style for Docker

func (*Docker) SystemLogCmd added in v1.3.0

func (r *Docker) SystemLogCmd(len int) string

SystemLogCmd returns the command to retrieve system logs

func (*Docker) UnpauseContainers added in v1.7.0

func (r *Docker) UnpauseContainers(ids []string) error

UnpauseContainers unpauses a container based on ID

func (*Docker) Version added in v1.0.0

func (r *Docker) Version() (string, error)

Version retrieves the current version of this runtime

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 ListOptions added in v1.7.0

type ListOptions 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
}

ListOptions are the options to use for listing containers

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, 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

	// ImageExists takes image name and image sha checks if an it exists
	ImageExists(string, string) bool

	// ListContainers returns a list of managed by this container runtime
	ListContainers(ListOptions) ([]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.KubernetesConfig) error
	// ImagesPreloaded returns true if all images have been preloaded
	ImagesPreloaded([]string) bool
}

Manager is a common interface for container runtimes

func New

func New(c Config) (Manager, error)

New returns an appropriately configured runtime

Jump to

Keyboard shortcuts

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