Documentation ¶
Index ¶
- Constants
- Variables
- func ContainerExists(ociBin string, name string, warnSlow ...bool) (bool, error)
- func ContainerID(ociBin string, nameOrID string) (string, error)
- func ContainerIPs(ociBin string, name string) (string, string, error)
- func ContainerRunning(ociBin string, name string, warnSlow ...bool) (bool, error)
- func ContainerStatus(ociBin string, name string, warnSlow ...bool) (state.State, error)
- func CreateContainerNode(p CreateParams) error
- func CreateNetwork(ociBin string, networkName string) (net.IP, error)
- func DaemonHost(driver string) string
- func DeleteAllVolumesByLabel(ctx context.Context, ociBin string, label string, warnSlow ...bool) []error
- func DeleteContainer(ctx context.Context, ociBin string, name string) error
- func DeleteContainersByLabel(ociBin string, label string) []error
- func DeleteKICNetworks(ociBin string) []error
- func ExtractTarballToVolume(ociBin string, tarballPath, volumeName, imageName string) error
- func ForwardedPort(ociBin string, ociID string, contPort int) (int, error)
- func HasMemoryCgroup() bool
- func InitialEnv(env string) string
- func IsCgroup2UnifiedMode() (bool, error)
- func IsCreatedByMinikube(ociBin string, nameOrID string) bool
- func IsExternalDaemonHost(driver string) bool
- func ListContainersByLabel(ctx context.Context, ociBin string, label string, warnSlow ...bool) ([]string, error)
- func ListOwnedContainers(ociBin string) ([]string, error)
- func LogContainerDebug(ociBin string, name string) string
- func LookupInitialEnv(env string) (string, bool)
- func PointToHostDockerDaemon() error
- func PointToHostPodman() error
- func PrefixCmd(cmd *exec.Cmd) *exec.Cmd
- func PrepareContainerNode(p CreateParams) error
- func PruneAllVolumesByLabel(ctx context.Context, ociBin string, label string, warnSlow ...bool) []error
- func RemoveNetwork(ociBin string, name string) error
- func RemoveVolume(ociBin string, name string) error
- func RoutableHostIPFromInside(ociBin string, clusterName string, containerName string) (net.IP, error)
- func ShutDown(ociBin string, name string) error
- func StartContainer(ociBin string, container string) error
- type CreateParams
- type FailFastError
- type Mount
- type MountPropagation
- type PortMapping
- type RunResult
- type SysInfo
Constants ¶
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 ¶
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
var ErrDaemonInfo = errors.New("daemon info not responding")
ErrDaemonInfo is thrown when docker/podman info is failing or not responding
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.
var ErrIPinUse = &FailFastError{errors.New("can't create with that IP, address already in use")}
ErrIPinUse is thrown when the container been given an IP used by another container
var ErrInsufficientDockerStorage = &FailFastError{errors.New("insufficient docker storage, no space left on device")}
ErrInsufficientDockerStorage is thrown when there is not more storage for docker
var ErrMinDockerVersion = &FailFastError{errors.New("docker version is less than the minimum required")}
ErrMinDockerVersion is thrown when docker version is less than minimum requited by Minikube
var ErrNetworkGatewayTaken = errors.New("network gateway is taken")
ErrNetworkGatewayTaken is when given network gatway is taken
var ErrNetworkInUse = errors.New("unable to delete a network that is attached to a running container")
ErrNetworkInUse is when trying to delete a network which is attached to another container
var ErrNetworkNotFound = errors.New("kic network not found")
ErrNetworkNotFound is when given network was not found
var ErrNetworkSubnetTaken = errors.New("subnet is taken")
ErrNetworkSubnetTaken is thrown when a subnet is taken by another network
var ErrVolumeNotFound = errors.New("kic volume not found")
ErrVolumeNotFound is when given volume was not found
var ErrWindowsContainers = &FailFastError{errors.New("docker container type is windows")}
ErrWindowsContainers is thrown when docker been configured to run windows containers instead of Linux
var MountPropagationNameToValue = map[string]MountPropagation{ "None": MountPropagationNone, "HostToContainer": MountPropagationHostToContainer, "Bidirectional": MountPropagationBidirectional, }
MountPropagationNameToValue is a map of valid MountPropogation names to their values
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
ContainerExists checks if container name exists (either running or exited)
func ContainerID ¶
ContainerID returns id of a container name
func ContainerIPs ¶
ContainerIPs returns ipv4,ipv6, error of a container by their name
func ContainerRunning ¶ added in v1.10.0
ContainerRunning returns running state of a container
func ContainerStatus ¶ added in v1.8.0
ContainerStatus returns status of a container running,exited,...
func CreateContainerNode ¶
func CreateContainerNode(p CreateParams) error
CreateContainerNode creates a new container node
func CreateNetwork ¶ added in v1.14.0
CreateNetwork creates a network returns gateway and error, minikube creates one network per cluster
func DaemonHost ¶ added in v1.16.0
DaemonHost returns the ip/hostname where OCI daemon service for driver is running For Podman return the host part of CONTAINER_HOST environment variable if set For Docker return the host part of DOCKER_HOST environment variable if set or DefaultBindIPV4 otherwise
func DeleteAllVolumesByLabel ¶ added in v1.7.3
func DeleteAllVolumesByLabel(ctx context.Context, 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
DeleteContainer deletes a container by ID or Name
func DeleteContainersByLabel ¶ added in v1.8.0
DeleteContainersByLabel deletes all containers that have a specific label if there no containers found with the given label, it will return nil
func DeleteKICNetworks ¶ added in v1.14.0
DeleteKICNetworks deletes all networks created by kic
func ExtractTarballToVolume ¶ added in v1.8.0
ExtractTarballToVolume runs a docker image imageName which extracts the tarball at tarballPath to the volume named volumeName
func ForwardedPort ¶ added in v1.9.0
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 HasMemoryCgroup ¶ added in v1.18.0
func HasMemoryCgroup() bool
HasMemoryCgroup checks whether it is possible to set memory limit for cgroup.
func InitialEnv ¶ added in v1.16.0
InitialEnv returns the value of the environment variable env before any environment changes made by minikube
func IsCgroup2UnifiedMode ¶ added in v1.18.0
IsCgroup2UnifiedMode returns whether we are running in cgroup 2 cgroup2 mode.
func IsCreatedByMinikube ¶ added in v1.8.0
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 IsExternalDaemonHost ¶ added in v1.16.0
IsExternalDaemonHost returns whether or not the OCI runtime is running on an external/virtual host For Podman driver return true if CONTAINER_HOST is set to a URI, and the URI contains a host item For Docker driver return true if DOCKER_HOST is set to a URI, and the URI contains a host item
func ListContainersByLabel ¶ added in v1.10.0
func ListContainersByLabel(ctx context.Context, ociBin string, label string, warnSlow ...bool) ([]string, error)
ListContainersByLabel returns all the container names with a specified label
func ListOwnedContainers ¶
ListOwnedContainers lists all the containres that kic driver created on user's machine using a label
func LogContainerDebug ¶ added in v1.12.0
LogContainerDebug will print relevant docker/podman infos after a container fails
func LookupInitialEnv ¶ added in v1.16.0
LookupInitialEnv returns the value of the environment variable env before any environment changes made by minikube
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 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(ctx context.Context, 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 RemoveNetwork ¶ added in v1.14.0
RemoveNetwork removes a network
func RemoveVolume ¶ added in v1.18.0
RemoveVolume removes a volume
func RoutableHostIPFromInside ¶ added in v1.8.0
func RoutableHostIPFromInside(ociBin string, clusterName 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
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
StartContainer starts a container with "docker/podman start"
Types ¶
type CreateParams ¶
type CreateParams struct { ClusterName string // cluster(profile name) that this container belongs to 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 Network string // network name that the container will attach to IP string // static IP to assign for th container in the cluster network }
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
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
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 Rootless bool // Weather or not the docker is running on rootless mode StorageDriver string // the storage driver for the daemon (for example overlay2) Errors []string // any server issues }
SysInfo Info represents common system Information between docker and podman that minikube cares
func CachedDaemonInfo ¶ added in v1.12.2
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
DaemonInfo returns common docker/podman daemon system info that minikube cares about