tools

package
v0.9.5-test1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2018 License: Apache-2.0 Imports: 32 Imported by: 8

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BindFlags

func BindFlags(flags *pflag.FlagSet) clientcmd.ClientConfig

func InPlugin

func InPlugin() bool

func NewDumpMetadataCmd

func NewDumpMetadataCmd(client KubeClient) *cobra.Command

NewDumpMetadataCmd returns a cobra.Command that dumps Virtlet metadata

func NewInstallCmd

func NewInstallCmd(rootCmd *cobra.Command, executablePath, homeDir string) *cobra.Command

NewInstallCmd returns a cobra.Command that installs virtletctl as a kubectl plugin.

func NewSshCmd

func NewSshCmd(client KubeClient, out io.Writer, sshExecutable string) *cobra.Command

NewSshCmd returns a cobra.Command that performs ssh into a VM pod.

func NewVirshCmd

func NewVirshCmd(client KubeClient, out io.Writer) *cobra.Command

NewVirshCmd returns a cobra.Command that executes virsh for a VM pod.

func SetLocalPluginFlags

func SetLocalPluginFlags(cmd *cobra.Command) error

Types

type ForwardedPort

type ForwardedPort struct {
	// LocalPort specifies the local port to use. 0 means selecting
	// a random local port.
	LocalPort uint16
	// RemotePort specifies the remote (pod-side) port to use.
	RemotePort uint16
}

ForwardedPort specifies an entry for the PortForward request

func (ForwardedPort) String

func (fp ForwardedPort) String() string

type KubeClient

type KubeClient interface {
	// GetVirtletPodNames returns a list of names of the virtlet pods
	// present in the cluster.
	GetVirtletPodNames() ([]string, error)
	// GetVirtletPodNameForNode returns a name of the virtlet pod on
	// the specified k8s node.
	GetVirtletPodNameForNode(nodeName string) (string, error)
	// GetVMPodInfo returns then name of the virtlet pod and the vm container name for
	// the specified VM pod.
	GetVMPodInfo(podName string) (*VMPodInfo, error)
	// ExecInContainer given a pod, a container, a namespace and a command
	// executes that command inside the pod's container returning stdout and stderr output
	// as strings and an error if it has occurred.
	// The specified stdin, stdout and stderr are used as the
	// standard input / output / error streams of the remote command.
	// No TTY is allocated by this function stdin.
	ExecInContainer(podName, containerName, namespace string, stdin io.Reader, stdout, stderr io.Writer, command []string) (int, error)
	// ForwardPorts starts forwarding 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.
	// The function returns when the ports are ready for use or if/when an error occurs.
	// Close stopCh to stop the port forwarder.
	ForwardPorts(podName, namespace string, ports []*ForwardedPort) (stopCh chan struct{}, err error)
}

KubeClient contains methods for interfacing with Kubernetes clusters.

type Plugin

type Plugin struct {
	// Name is the name of the plugin.
	Name string `yaml:"name"`
	// ShortDesc is the short description of the plugin.
	ShortDesc string `yaml:"shortDesc"`
	// LongDesc is the detailed description of the plugin.
	LongDesc string `yaml:"longDesc,omitempty"`
	// Example is an example of plugin usage.
	Example string `yaml:"example,omitempty"`
	// Command is the command that needs to be run by kubectl
	// to execute the plugin.
	Command string `yaml:"command,omitempty"`
	// Flags describes the flags for this plugin.
	Flags []PluginFlag `yaml:"flags,omitempty"`
	// Tree lists the subcommands of this plugin.
	Tree []*Plugin `yaml:"tree,omitempty"`
}

Description holds everything needed to register a plugin as a command. Usually comes from a descriptor file.

type PluginFlag

type PluginFlag struct {
	// Name is the name of the flag
	Name string `yaml:"name"`
	// Shorthand is the shorthand for the flag, e.g. -o
	Shorthand string `yaml:"shorthand,omitempty"`
	// Desc is the description of the flag
	Desc string `yaml:"desc"`
	// DefValue is the default value of the flag.
	DefValue string `yaml:"defValue,omitempty"`
}

Flag describes a single flag supported by a given plugin.

type RealKubeClient

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

RealKubeClient is used to access a Kubernetes cluster.

func NewRealKubeClient

func NewRealKubeClient(clientCfg clientcmd.ClientConfig) *RealKubeClient

NewRealKubeClient creates a RealKubeClient for the specified ClientConfig.

func (*RealKubeClient) ExecInContainer

func (c *RealKubeClient) ExecInContainer(podName, containerName, namespace string, stdin io.Reader, stdout, stderr io.Writer, command []string) (int, error)

ExecInContainer implements ExecInContainer method of KubeClient interface

func (*RealKubeClient) ForwardPorts

func (c *RealKubeClient) ForwardPorts(podName, namespace string, ports []*ForwardedPort) (stopCh chan struct{}, err error)

ForwardPorts implements ForwardPorts method of KubeClient interface.

func (*RealKubeClient) GetVMPodInfo

func (c *RealKubeClient) GetVMPodInfo(podName string) (*VMPodInfo, error)

GetVMPodInfo implements GetVMPodInfo method of KubeClient interface.

func (*RealKubeClient) GetVirtletPodNameForNode

func (c *RealKubeClient) GetVirtletPodNameForNode(nodeName string) (string, error)

GetVirtletPodNameForNode implements GetVirtletPodNameForNode method of KubeClient interface.

func (*RealKubeClient) GetVirtletPodNames

func (c *RealKubeClient) GetVirtletPodNames() ([]string, error)

GetVirtletPodNames implements GetVirtletPodNames method of KubeClient interface.

type VMPodInfo

type VMPodInfo struct {
	// NodeName is the name of the node where the VM pod runs
	NodeName string
	// VirtletPodName is the name of the virtlet pod that manages this VM pod
	VirtletPodName string
	// ContainerId is the id of the container in the VM pod
	ContainerId string
	// ContainerName is the name of the container in the VM pod
	ContainerName string
}

VMPodInfo describes a VM pod in a way that's necessary for virtletctl to handle it

func (VMPodInfo) LibvirtDomainName

func (podInfo VMPodInfo) LibvirtDomainName() string

LibvirtDomainName returns the name of the libvirt domain for the VMPodInfo.

Jump to

Keyboard shortcuts

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