core

package
v0.1.13-beta3 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2020 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package core contains interfaces which define core kutti functionality, and some utility functions. Package core also provides a central place for drivers to register themselves. All drivers should call the RegisterDriver function with a unique name on init.

The interfaces are:

VMDriver

This defines the interface for kutti "drivers". Each driver should be able to manage:

- VM Hosts, which represent Kubernetes nodes

- VM Networks, which connect VM Hosts and manage DHCP etc

- VM Images, which allow templated creation of VM Hosts

VMNetwork

This defines a private network to which all nodes in a cluster will be connected. The network should allow connectivity between nodes, and public internet connectivity. For now, only IPv4 capability is assumed.

VMHost

This defines a host that will act as a Kubernetes node. The host should allow start, stop, force stop, and wait operations, and provide a way to connect to it via SSH.

VMImage

This defines an "image" from which a VMHost can be created. An image should have a unique name, a Kubernetes version, and a checksum facility.

Driver Management

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CacheDir

func CacheDir() (result string, err error)

CacheDir returns the location where the kutti cache should reside. The kutti cache contains images.

func ConfigDir

func ConfigDir() (result string, err error)

ConfigDir returns the location where the kutti config files reside. The kutti config files include driver-specific config files and image lists.

func ForEachDriver

func ForEachDriver(f func(VMDriver) bool)

ForEachDriver iterates over VM drivers. The callback function can return false to stop the iteration.

func RegisterDriver

func RegisterDriver(name string, d VMDriver)

RegisterDriver registers a VMdriver with a name to core. If a driver with the specified name already exists, it is replaced.

Types

type SSHClient

type SSHClient interface {
	RunWithResults(address string, command string) (string, error)
	RunInterativeShell(address string)
}

SSHClient defines a simple SSH client

type VMDriver

type VMDriver interface {
	Name() string
	Description() string
	RequiresPortForwarding() bool
	Status() string

	ListNetworks() ([]VMNetwork, error)
	CreateNetwork(netname string) (VMNetwork, error)
	GetNetwork(netname string) (VMNetwork, error)
	DeleteNetwork(netname string) error

	ListHosts() ([]VMHost, error)
	CreateHost(hostname string, networkname string, clustername string, k8sversion string) (VMHost, error)
	GetHost(hostname string, networkname string, clustername string) (VMHost, error)
	DeleteHost(hostname string, networkname string, clustername string) error

	FetchImageList() error
	ListImages() ([]VMImage, error)
	GetImage(k8sversion string) (VMImage, error)
}

VMDriver describes operations to manage VMNetworks, VMHosts and VMImages. The RequiresPortForwarding() method is particularly important. It is expected to return true if the VMNetworks of the driver use NAT. This means that ports of the VMHosts will need to be forwarded to physical ports for access.

func GetDriver

func GetDriver(name string) (VMDriver, bool)

GetDriver returns a VMDriver corresponding to the name. If there is no driver registered against the name, nil is returned.

type VMHost

type VMHost interface {
	Name() string
	Status() string
	SSHAddress() string

	Start() error
	Stop() error
	ForceStop() error
	WaitForStateChange(timeoutinseconds int)
	ForwardPort(hostport int, vmport int) error
	UnforwardPort(vmport int) error
	ForwardSSHPort(hostport int) error
}

VMHost describes a virtual host. In kutti, a VMHost can be started, stoppped normally and stopped forcibly. If the VMDriver and VMNetwork use NAT, then a VMHost can also have its ports forwarded to physical host ports.

type VMImage

type VMImage interface {
	K8sVersion() string
	Status() string

	Fetch() error
	FromFile(filepath string) error
	PurgeLocal() error
}

VMImage describes a template from which VMHosts are created. A VMDriver is expected to maintain a cache of VMImages locally. A VMImage may be downloaded from a driver-specific source using the Fetch method, or added to the cache from a local file using the FromFile method.

type VMNetwork

type VMNetwork interface {
	Name() string
	NetCIDR() string
}

VMNetwork describes a virtual network. A cluster of VMHosts are connected via a VMNetwork. A VMNetwork manages VMHost IP addresses.

Jump to

Keyboard shortcuts

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