framework

package
v0.9.4-test5 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2018 License: Apache-2.0 Imports: 36 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrTimeout = fmt.Errorf("timeout")

ErrTimeout is the timeout error returned from functions wrapped by WithTimeout

Functions

func Curl

func Curl(url string) (string, error)

func Exec

func Exec(executor Executor, command []string, input string) (string, string, int, error)

Exec executes command with the given executor and returns stdout/stderr/exitCode as strings

func ExecSimple

func ExecSimple(executor Executor, command ...string) (string, error)

ExecSimple is a simplified version of Exec that verifies exit code/stderr internally and returns stdout only

func RunVirsh

func RunVirsh(virtletPod *PodInterface, command ...string) (string, error)

RunVirsh runs virsh command in the given virtlet pod

func WithTimeout

func WithTimeout(timeout time.Duration, fn func() error) func() error

WithTimeout adds timeout to synchronous function

Types

type Controller

type Controller struct {
	// contains filtered or unexported fields
}

Controller is the entry point for various operations on k8s+virtlet entities

func NewController

func NewController(namespace string) (*Controller, error)

NewController creates instance of controller for specified k8s namespace. If namespace is empty string then namespace with random name is going to be created

func (*Controller) ConfigMaps

func (c *Controller) ConfigMaps() typedv1.ConfigMapInterface

ConfigMaps returns interface for ConfigMap objects

func (*Controller) CreateVirtletImageMapping

func (*Controller) DeleteVirtletImageMapping

func (c *Controller) DeleteVirtletImageMapping(name string) error

func (*Controller) DinDNodeExecutor

func (c *Controller) DinDNodeExecutor(name string) (Executor, error)

DinDNodeExecutor returns executor in DinD container for one of k8s nodes

func (*Controller) DockerContainer

func (c *Controller) DockerContainer(name string) (*DockerContainerInterface, error)

DockerContainer returns interface for operations on a docker container with a given name

func (*Controller) Finalize

func (c *Controller) Finalize() error

Finalize deletes random namespace that might has been created by NewController

func (*Controller) FindPod

func (c *Controller) FindPod(namespace string, labelMap map[string]string,
	predicate func(podInterface *PodInterface) bool) (*PodInterface, error)

FindPod looks for a pod in a given namespace having specified labels and matching optional predicate function

func (*Controller) Namespace

func (c *Controller) Namespace() string

Namespace returns default controller namespace name

func (*Controller) PersistentVolumeClaimsClient

func (c *Controller) PersistentVolumeClaimsClient() typedv1.PersistentVolumeClaimInterface

PersistentVolumeClaimsClient returns interface for PVCs

func (*Controller) PersistentVolumesClient

func (c *Controller) PersistentVolumesClient() typedv1.PersistentVolumeInterface

PersistentVolumesClient returns interface for PVs

func (*Controller) Pod

func (c *Controller) Pod(name, namespace string) (*PodInterface, error)

Pod returns interface for operations on k8s pod in a given namespace. If namespace is an empty string then default controller namespace is used

func (*Controller) RunPod

func (c *Controller) RunPod(name, image string, command []string, timeout time.Duration, exposePorts ...int32) (*PodInterface, error)

RunPod is a helper method to create a pod in a simple configuration (similar to `kubectl run`)

func (*Controller) Secrets

func (c *Controller) Secrets() typedv1.SecretInterface

Secrets returns interface for Secret objects

func (*Controller) VM

func (c *Controller) VM(name string) *VMInterface

VM returns interface for operations on virtlet VM pods

func (*Controller) VirtletNodeName

func (c *Controller) VirtletNodeName() (string, error)

VirtletNodeName returns the name of one of the nodes that run virtlet

func (*Controller) VirtletPod

func (c *Controller) VirtletPod() (*PodInterface, error)

VirtletPod returns one of the active virtlet pods

type DockerContainerExecInterface

type DockerContainerExecInterface struct {
	// contains filtered or unexported fields
}

DockerContainerExecInterface is the receiver object for commands execution in docker container

func (*DockerContainerExecInterface) Close

Close closes the executor

func (*DockerContainerExecInterface) Exec

func (n *DockerContainerExecInterface) Exec(command []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)

Exec executes command in docker container

type DockerContainerInterface

type DockerContainerInterface struct {
	Name string
	ID   string
	// contains filtered or unexported fields
}

DockerContainerInterface is the receiver object for docker container operations

func (*DockerContainerInterface) Container

func (d *DockerContainerInterface) Container() (*types.Container, error)

Container returns info for the container associated with method receiver

func (*DockerContainerInterface) Delete

func (d *DockerContainerInterface) Delete() error

Delete deletes docker container

func (*DockerContainerInterface) Executor

func (d *DockerContainerInterface) Executor(privileged bool, user string) Executor

Executor returns interface to run commands in docker container

func (*DockerContainerInterface) PullImage

func (d *DockerContainerInterface) PullImage(name string) error

PullImage pulls docker image from remote registry

func (*DockerContainerInterface) Run

func (d *DockerContainerInterface) Run(image string, env map[string]string, network string, ports []string, privileged bool, cmd ...string) error

Run starts new docker container (similar to `docker run`)

type Executor

type Executor interface {
	io.Closer
	Exec(command []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)
}

Executor is the interface to execute shell commands in arbitrary places

type LocalCmd

type LocalCmd struct {
	// contains filtered or unexported fields
}

func LocalExecutor

func LocalExecutor(ctx context.Context) *LocalCmd

func (*LocalCmd) Close

func (l *LocalCmd) Close() error

func (*LocalCmd) Exec

func (l *LocalCmd) Exec(command []string, stdin io.Reader, stdout, stderr io.Writer) (int, error)

type PodInterface

type PodInterface struct {
	Pod *v1.Pod
	// contains filtered or unexported fields
}

PodInterface provides API to work with a pod

func (*PodInterface) Container

func (pi *PodInterface) Container(name string) (Executor, error)

Container returns interface to execute commands in one of pod's containers

func (*PodInterface) Create

func (pi *PodInterface) Create() error

Create creates pod in the k8s

func (*PodInterface) Delete

func (pi *PodInterface) Delete() error

Delete deletes the pod and associated service, which was earlier created by `controller.Run()`

func (*PodInterface) DinDNodeExecutor

func (pi *PodInterface) DinDNodeExecutor() (Executor, error)

DinDNodeExecutor return DinD executor for node, where this pod is located

func (*PodInterface) Wait

func (pi *PodInterface) Wait(timing ...time.Duration) error

Wait waits for pod to start and checks that it doesn't fail immediately after that

func (*PodInterface) WaitDestruction

func (pi *PodInterface) WaitDestruction(timing ...time.Duration) error

WaitDestruction waits for the pod to be deleted

type VMInterface

type VMInterface struct {
	Name string
	// contains filtered or unexported fields
}

VMInterface provides API to work with virtlet VM pods

func (*VMInterface) Create

func (vmi *VMInterface) Create(options VMOptions, waitTimeout time.Duration, beforeCreate func(*PodInterface)) error

Create create new virtlet VM pod in k8s

func (*VMInterface) Delete

func (vmi *VMInterface) Delete(waitTimeout time.Duration) error

Delete deletes VM pod and waits for it to disappear from k8s

func (*VMInterface) Domain

func (vmi *VMInterface) Domain() (libvirtxml.Domain, error)

Domain returns libvirt domain definition for the VM

func (*VMInterface) DomainName

func (vmi *VMInterface) DomainName() (string, error)

DomainName returns libvirt domain name the VM

func (*VMInterface) Pod

func (vmi *VMInterface) Pod() (*PodInterface, error)

Pod returns ensures that underlying is started and returns it

func (*VMInterface) SSH

func (vmi *VMInterface) SSH(user, secret string) (Executor, error)

SSH returns SSH executor that can run commands in VM

func (*VMInterface) VirshCommand

func (vmi *VMInterface) VirshCommand(command ...string) (string, error)

VirshCommand runs virsh command in the virtlet pod, responsible for this VM Domain name is automatically substituted into commandline in place of `<domain>`

func (*VMInterface) VirtletPod

func (vmi *VMInterface) VirtletPod() (*PodInterface, error)

VirtletPod returns pod in which virtlet instance, responsible for this VM is located (i.e. kube-system:virtlet-xxx pod on the same node)

type VMOptions

type VMOptions struct {
	Image             string
	VCPUCount         int
	SSHKey            string
	SSHKeySource      string
	CloudInitScript   string
	DiskDriver        string
	Limits            map[string]string
	UserData          string
	OverwriteUserData bool
	UserDataScript    string
	UserDataSource    string
	NodeName          string
}

VMOptions defines VM parameters

Jump to

Keyboard shortcuts

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