oci

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Mar 13, 2020 License: Apache-2.0 Imports: 18 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 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) (bool, error)

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

func ContainerID

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

ContainerID returns id of a container name

func ContainerIPs

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

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

func ContainerStatus added in v1.8.0

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

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

func Copy

func Copy(ociBinary string, ociID string, targetDir string, fName string) error

Copy copies a local asset into the container

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) []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(tarballPath, volumeName, imageName string) error

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

func HostPortBinding

func HostPortBinding(ociBinary string, ociID string, contPort int) (int, error)

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

func IsCreatedByMinikube added in v1.8.0

func IsCreatedByMinikube(ociBinary 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 ListOwnedContainers

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

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

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 PruneAllVolumesByLabel added in v1.7.3

func PruneAllVolumesByLabel(ociBin string, label string) []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

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

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 SysInfo added in v1.8.0

type SysInfo struct {
	CPUs        int   // CPUs is Number of CPUs
	TotalMemory int64 // TotalMemory Total available ram
}

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

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