oci

package
v1.13.0 Latest Latest
Warning

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

Go to latest
Published: Sep 3, 2020 License: Apache-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// DefaultBindIPV4 is The default IP the container will listen on.
	DefaultBindIPV4 = "127.0.0.1"
	// Docker is docker
	Docker = "docker"
	// Podman is podman
	Podman = "podman"
	// ProfileLabelKey is applied to any container or volume created by a specific minikube profile name.minikube.sigs.k8s.io=PROFILE_NAME
	ProfileLabelKey = "name.minikube.sigs.k8s.io"
	// NodeLabelKey is applied to each volume so it can be referred to by name
	NodeLabelKey = "mode.minikube.sigs.k8s.io"

	// CreatedByLabelKey is applied to any container/volume that is created by minikube created_by.minikube.sigs.k8s.io=true
	CreatedByLabelKey = "created_by.minikube.sigs.k8s.io"
)

Variables

View Source
var ErrCPUCountLimit = &FailFastError{errors.New("not enough CPUs is available for container")}

ErrCPUCountLimit is thrown when docker daemon doesn't have enough CPUs for the requested container

View Source
var ErrDaemonInfo = errors.New("daemon info not responding")

ErrDaemonInfo is thrown when docker/podman info is failing or not responding

View Source
var ErrExitedUnexpectedly = errors.New("container exited unexpectedly")

ErrExitedUnexpectedly is thrown when container is created/started without error but later it exists and it's status is not running anymore.

View Source
var ErrWindowsContainers = &FailFastError{errors.New("docker container type is windows")}

ErrWindowsContainers is thrown when docker been configured to run windows containers instead of Linux

View Source
var MountPropagationNameToValue = map[string]MountPropagation{
	"None":            MountPropagationNone,
	"HostToContainer": MountPropagationHostToContainer,
	"Bidirectional":   MountPropagationBidirectional,
}

MountPropagationNameToValue is a map of valid MountPropogation names to their values

View Source
var MountPropagationValueToName = map[MountPropagation]string{
	MountPropagationNone:            "None",
	MountPropagationHostToContainer: "HostToContainer",
	MountPropagationBidirectional:   "Bidirectional",
}

MountPropagationValueToName is a map of valid MountPropogation values to their string names

Functions

func ContainerExists added in v1.8.0

func ContainerExists(ociBin string, name string, warnSlow ...bool) (bool, error)

ContainerExists checks if container name exists (either running or exited)

func ContainerID

func ContainerID(ociBin string, nameOrID string) (string, error)

ContainerID returns id of a container name

func ContainerIPs

func ContainerIPs(ociBin string, name string) (string, string, error)

ContainerIPs returns ipv4,ipv6, error of a container by their name

func ContainerRunning added in v1.10.0

func ContainerRunning(ociBin string, name string, warnSlow ...bool) (bool, error)

ContainerRunning returns running state of a container

func ContainerStatus added in v1.8.0

func ContainerStatus(ociBin string, name string, warnSlow ...bool) (state.State, error)

ContainerStatus returns status of a container running,exited,...

func CreateContainerNode

func CreateContainerNode(p CreateParams) error

CreateContainerNode creates a new container node

func DeleteAllVolumesByLabel added in v1.7.3

func DeleteAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []error

DeleteAllVolumesByLabel deletes all volumes that have a specific label if there is no volume to delete it will return nil

func DeleteContainer added in v1.8.0

func DeleteContainer(ociBin string, name string) error

DeleteContainer deletes a container by ID or Name

func DeleteContainersByLabel added in v1.8.0

func DeleteContainersByLabel(ociBin string, label string) []error

DeleteContainersByLabel deletes all containers that have a specific label if there no containers found with the given label, it will return nil

func ExtractTarballToVolume added in v1.8.0

func ExtractTarballToVolume(ociBin string, tarballPath, volumeName, imageName string) error

ExtractTarballToVolume runs a docker image imageName which extracts the tarball at tarballPath to the volume named volumeName

func ForwardedPort added in v1.9.0

func ForwardedPort(ociBin string, ociID string, contPort int) (int, error)

ForwardedPort will return port mapping for a container using cli. example : ForwardedPort("docker", "minikube", "22") will return the docker assigned port: 32769, nil only supports TCP ports

func IsCreatedByMinikube added in v1.8.0

func IsCreatedByMinikube(ociBin string, nameOrID string) bool

IsCreatedByMinikube returns true if the container was created by minikube with default assumption that it is not created by minikube when we don't know for sure

func ListContainersByLabel added in v1.10.0

func ListContainersByLabel(ociBin string, label string, warnSlow ...bool) ([]string, error)

ListContainersByLabel returns all the container names with a specified label

func ListOwnedContainers

func ListOwnedContainers(ociBin string) ([]string, error)

ListOwnedContainers lists all the containres that kic driver created on user's machine using a label

func LogContainerDebug added in v1.12.0

func LogContainerDebug(ociBin string, name string) string

LogContainerDebug will print relevant docker/podman infos after a container fails

func PointToHostDockerDaemon

func PointToHostDockerDaemon() error

PointToHostDockerDaemon will unset env variables that point to docker inside minikube to make sure it points to the docker daemon installed by user.

func PointToHostPodman added in v1.10.0

func PointToHostPodman() error

PointToHostPodman will unset env variables that point to podman inside minikube

func PrefixCmd added in v1.10.0

func PrefixCmd(cmd *exec.Cmd) *exec.Cmd

PrefixCmd adds any needed prefix (such as sudo) to the command

func PrepareContainerNode added in v1.10.0

func PrepareContainerNode(p CreateParams) error

PrepareContainerNode sets up the container node before CreateContainerNode is called. For the container runtime, it creates a volume which will be mounted into kic

func PruneAllVolumesByLabel added in v1.7.3

func PruneAllVolumesByLabel(ociBin string, label string, warnSlow ...bool) []error

PruneAllVolumesByLabel deletes all volumes that have a specific label if there is no volume to delete it will return nil example: docker volume prune -f --filter label=name.minikube.sigs.k8s.io=minikube

func RoutableHostIPFromInside added in v1.8.0

func RoutableHostIPFromInside(ociBin string, containerName string) (net.IP, error)

RoutableHostIPFromInside returns the ip/dns of the host that container lives on is routable from inside the container

func ShutDown added in v1.10.0

func ShutDown(ociBin string, name string) error

ShutDown will run command to shut down the container to ensure the containers process and networking bindings are all closed to avoid containers getting stuck before delete https://github.com/kubernetes/minikube/issues/7657

func StartContainer added in v1.10.0

func StartContainer(ociBin string, container string) error

StartContainer starts a container with "docker/podman start"

Types

type CreateParams

type CreateParams struct {
	Name          string            // used for container name and hostname
	Image         string            // container image to use to create the node.
	ClusterLabel  string            // label the clusters we create using minikube so we can clean up
	NodeLabel     string            // label the nodes so we can clean up by node name
	Role          string            // currently only role supported is control-plane
	Mounts        []Mount           // volume mounts
	APIServerPort int               // Kubernetes api server port
	PortMappings  []PortMapping     // ports to map to container from host
	CPUs          string            // number of cpu cores assign to container
	Memory        string            // memory (mbs) to assign to the container
	Envs          map[string]string // environment variables to pass to the container
	ExtraArgs     []string          // a list of any extra option to pass to oci binary during creation time, for example --expose 8080...
	OCIBinary     string            // docker or podman
}

CreateParams are parameters needed to create a container

type FailFastError added in v1.12.0

type FailFastError struct {
	Err error
}

FailFastError type is an error that could not be solved by trying again

func (*FailFastError) Error added in v1.12.0

func (f *FailFastError) Error() string

type Mount

type Mount struct {
	// Path of the mount within the container.
	ContainerPath string `protobuf:"bytes,1,opt,name=container_path,json=containerPath,proto3" json:"containerPath,omitempty"`
	// Path of the mount on the host. If the hostPath doesn't exist, then runtimes
	// should report error. If the hostpath is a symbolic link, runtimes should
	// follow the symlink and mount the real destination to container.
	HostPath string `protobuf:"bytes,2,opt,name=host_path,json=hostPath,proto3" json:"hostPath,omitempty"`
	// If set, the mount is read-only.
	Readonly bool `protobuf:"varint,3,opt,name=readonly,proto3,json=readOnly,proto3" json:"readOnly,omitempty"`
	// If set, the mount needs SELinux relabeling.
	SelinuxRelabel bool `protobuf:"varint,4,opt,name=selinux_relabel,json=selinuxRelabel,proto3" json:"selinuxRelabel,omitempty"`
	// Requested propagation mode.
	Propagation MountPropagation `protobuf:"varint,5,opt,name=propagation,proto3,enum=runtime.v1alpha2.MountPropagation" json:"propagation,omitempty"`
}

Mount specifies a host volume to mount into a container. This is a close copy of the upstream cri Mount type see: k8s.io/kubernetes/pkg/kubelet/apis/cri/runtime/v1alpha2 It additionally serializes the "propagation" field with the string enum names on disk as opposed to the int32 values, and the serlialzed field names have been made closer to core/v1 VolumeMount field names In yaml this looks like:

containerPath: /foo
hostPath: /bar
readOnly: true
selinuxRelabel: false
propagation: None

Propagation may be one of: None, HostToContainer, Bidirectional

func ParseMountString added in v1.13.0

func ParseMountString(spec string) (m Mount, err error)

ParseMountString parses a mount string of format: '[host-path:]container-path[:<options>]' The comma-delimited 'options' are [rw|ro], [Z], [srhared|rslave|rprivate].

type MountPropagation

type MountPropagation int32

MountPropagation represents an "enum" for mount propagation options, see also Mount.

const (
	// MountPropagationNone specifies that no mount propagation
	// ("private" in Linux terminology).
	MountPropagationNone MountPropagation = 0
	// MountPropagationHostToContainer specifies that mounts get propagated
	// from the host to the container ("rslave" in Linux).
	MountPropagationHostToContainer MountPropagation = 1
	// MountPropagationBidirectional specifies that mounts get propagated from
	// the host to the container and from the container to the host
	// ("rshared" in Linux).
	MountPropagationBidirectional MountPropagation = 2
)

type PortMapping

type PortMapping struct {
	// Port within the container.
	ContainerPort int32 `protobuf:"varint,1,opt,name=container_port,json=containerPort,proto3" json:"containerPort,omitempty"`
	// Port on the host.
	HostPort      int32  `protobuf:"varint,2,opt,name=host_path,json=hostPort,proto3" json:"hostPort,omitempty"`
	ListenAddress string `protobuf:"bytes,3,opt,name=listenAddress,json=hostPort,proto3" json:"listenAddress,omitempty"`
}

PortMapping specifies a host port mapped into a container port. In yaml this looks like:

containerPort: 80
hostPort: 8000
listenAddress: 127.0.0.1

type RunResult added in v1.10.0

type RunResult struct {
	Stdout   bytes.Buffer
	Stderr   bytes.Buffer
	ExitCode int
	Args     []string // the args that was passed to Runner
}

RunResult holds the results of a Runner

func (RunResult) Command added in v1.10.0

func (rr RunResult) Command() string

Command returns a human readable command string that does not induce eye fatigue

func (RunResult) Output added in v1.10.0

func (rr RunResult) Output() string

Output returns human-readable output for an execution result

type SysInfo added in v1.8.0

type SysInfo struct {
	CPUs          int    // CPUs is Number of CPUs
	TotalMemory   int64  // TotalMemory Total available ram
	OSType        string // container's OsType (windows or linux)
	Swarm         bool   // Weather or not the docker swarm is active
	StorageDriver string // the storage driver for the daemon  (for example overlay2)
}

SysInfo Info represents common system Information between docker and podman that minikube cares

func CachedDaemonInfo added in v1.12.2

func CachedDaemonInfo(ociBin string) (SysInfo, error)

CachedDaemonInfo will run and return a docker/podman info only once per minikube run time. to avoid performance

func DaemonInfo added in v1.8.0

func DaemonInfo(ociBin string) (SysInfo, error)

DaemonInfo returns common docker/podman daemon system info that minikube cares about

Jump to

Keyboard shortcuts

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