Documentation ¶
Index ¶
- Variables
- func Curl(url string) (string, error)
- func Run(executor Executor, input string, command ...string) (string, string, error)
- func RunSimple(executor Executor, command ...string) (string, error)
- func RunVirsh(virtletPod *PodInterface, command ...string) (string, error)
- func WithTimeout(timeout time.Duration, fn func() error) func() error
- type Command
- type CommandError
- type Controller
- func (c *Controller) ConfigMaps() typedv1.ConfigMapInterface
- func (c *Controller) CreateVirtletImageMapping(mapping virtlet_v1.VirtletImageMapping) (*virtlet_v1.VirtletImageMapping, error)
- func (c *Controller) DeleteVirtletImageMapping(name string) error
- func (c *Controller) DinDNodeExecutor(name string) (Executor, error)
- func (c *Controller) DockerContainer(name string) (*DockerContainerInterface, error)
- func (c *Controller) Finalize() error
- func (c *Controller) FindPod(namespace string, labelMap map[string]string, ...) (*PodInterface, error)
- func (c *Controller) Namespace() string
- func (c *Controller) PersistentVolumeClaimsClient() typedv1.PersistentVolumeClaimInterface
- func (c *Controller) PersistentVolumesClient() typedv1.PersistentVolumeInterface
- func (c *Controller) Pod(name, namespace string) (*PodInterface, error)
- func (c *Controller) RunPod(name, image string, command []string, timeout time.Duration, ...) (*PodInterface, error)
- func (c *Controller) Secrets() typedv1.SecretInterface
- func (c *Controller) VM(name string) *VMInterface
- func (c *Controller) VirtletNodeName() (string, error)
- func (c *Controller) VirtletPod() (*PodInterface, error)
- type DockerContainerExecInterface
- type DockerContainerInterface
- func (d *DockerContainerInterface) Container() (*types.Container, error)
- func (d *DockerContainerInterface) Delete() error
- func (d *DockerContainerInterface) Executor(privileged bool, user string) Executor
- func (d *DockerContainerInterface) PullImage(name string) error
- func (d *DockerContainerInterface) Run(image string, env map[string]string, network string, ports []string, ...) error
- type Executor
- type LocalCmd
- type PodInterface
- func (pi *PodInterface) Container(name string) (Executor, error)
- func (pi *PodInterface) Create() error
- func (pi *PodInterface) Delete() error
- func (pi *PodInterface) DinDNodeExecutor() (Executor, error)
- func (pi *PodInterface) PortForward(ports []*tools.ForwardedPort) (chan struct{}, error)
- func (pi *PodInterface) Wait(timing ...time.Duration) error
- func (pi *PodInterface) WaitDestruction(timing ...time.Duration) error
- type VMInterface
- func (vmi *VMInterface) Create(options VMOptions, waitTimeout time.Duration, beforeCreate func(*PodInterface)) error
- func (vmi *VMInterface) Delete(waitTimeout time.Duration) error
- func (vmi *VMInterface) Domain() (libvirtxml.Domain, error)
- func (vmi *VMInterface) DomainName() (string, error)
- func (vmi *VMInterface) Pod() (*PodInterface, error)
- func (vmi *VMInterface) SSH(user, secret string) (Executor, error)
- func (vmi *VMInterface) VirshCommand(command ...string) (string, error)
- func (vmi *VMInterface) VirtletPod() (*PodInterface, error)
- type VMOptions
Constants ¶
This section is empty.
Variables ¶
var ClusterURL = flag.String("cluster-url", "http://127.0.0.1:8080", "apiserver URL")
var ErrTimeout = fmt.Errorf("timeout")
ErrTimeout is the timeout error returned from functions wrapped by WithTimeout
Functions ¶
func Run ¶ added in v1.0.0
Run executes command with the given executor, returns stdout/stderr as strings and exit code in CommandError
func RunSimple ¶ added in v1.0.0
RunSimple is a simplified version of Run that verifies exit code/stderr internally and returns stdout only
Types ¶
type Command ¶ added in v1.0.0
Command is the interface to control the command started with an Executor
type CommandError ¶ added in v1.0.0
type CommandError struct {
ExitCode int
}
CommandError holds an exit code for commands finished without any Executor error
func (CommandError) Error ¶ added in v1.0.0
func (e CommandError) Error() string
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 (c *Controller) CreateVirtletImageMapping(mapping virtlet_v1.VirtletImageMapping) (*virtlet_v1.VirtletImageMapping, error)
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 ¶
func (*DockerContainerExecInterface) Close() error
Close closes the executor
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
type Executor ¶
type Executor interface { io.Closer Run(stdin io.Reader, stdout, stderr io.Writer, command ...string) error Start(stdin io.Reader, stdout, stderr io.Writer, command ...string) (Command, error) }
Executor is the interface to run shell commands in arbitrary places
type LocalCmd ¶
type LocalCmd struct {
// contains filtered or unexported fields
}
func LocalExecutor ¶
type PodInterface ¶
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) 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) PortForward ¶ added in v1.0.0
func (pi *PodInterface) PortForward(ports []*tools.ForwardedPort) (chan struct{}, error)
PortForward starts port forwarding to the specified ports to the specified pod in background. If a port entry has LocalPort = 0, it's updated with the real port number that was selected by the forwarder. Close returned channel to stop the port forwarder.
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