Documentation
¶
Overview ¶
Package driverhyperv implements a kutti driver for Microsoft Hyper-V. It uses the Hyper-V PowerShell module to talk to Hyper-V. It invokes Cmdlets from the module via an interface script.
For cluster networking, it uses the Hyper-V default switch.
For nodes, it creates virtual machines with pre-set settings, and attaches differencing VHDX disks backed by master images maintained by the companion driver-hyperv-images project.
For images, it uses the aforesaid VHDX files, downloading the list from the URL pointed to by the ImagesSourceURL variable.
The details of individual operations can be found in the online documentation. Details about the interface between the driver and a running VM can be found at the driver-hyperv-images project: https://github.com/kuttiproject/driver-hyperv-images
Index ¶
- Constants
- Variables
- type Driver
- func (vd *Driver) DeleteMachine(machinename string, clustername string) error
- func (vd *Driver) DeleteNetwork(clustername string) error
- func (vd *Driver) Description() string
- func (vd *Driver) Error() string
- func (vd *Driver) GetImage(k8sversion string) (drivercore.Image, error)
- func (vd *Driver) GetMachine(machinename string, clustername string) (drivercore.Machine, error)
- func (vd *Driver) K8sVersions() []string
- func (vd *Driver) ListImages() ([]drivercore.Image, error)
- func (vd *Driver) Name() string
- func (vd *Driver) NewMachine(machinename string, clustername string, k8sversion string) (drivercore.Machine, error)
- func (vd *Driver) NewNetwork(clustername string) (drivercore.Network, error)
- func (vd *Driver) QualifiedMachineName(machinename string, clustername string) string
- func (vd *Driver) QualifiedNetworkName(clustername string) string
- func (vd *Driver) Status() string
- func (vd *Driver) UpdateImageList() error
- func (vd *Driver) UsesNATNetworking() bool
- func (vd *Driver) UsesPerClusterNetworking() bool
- func (vd *Driver) ValidK8sVersion(k8sversion string) bool
- type Image
- type Machine
- func (vh *Machine) Error() string
- func (vh *Machine) ExecuteCommand(command drivercore.PredefinedCommand, params ...string) error
- func (vh *Machine) ForceStop() error
- func (vh *Machine) ForwardPort(hostport int, machineport int) error
- func (vh *Machine) ForwardSSHPort(hostport int) error
- func (vh *Machine) IPAddress() string
- func (vh *Machine) ImplementsCommand(command drivercore.PredefinedCommand) bool
- func (vh *Machine) Name() string
- func (vh *Machine) SSHAddress() string
- func (vh *Machine) Start() error
- func (vh *Machine) Status() drivercore.MachineStatus
- func (vh *Machine) Stop() error
- func (vh *Machine) UnforwardPort(machineport int) error
- func (vh *Machine) WaitForStateChange(timeoutinseconds int)
Constants ¶
const ( MachineStatusStarting = drivercore.MachineStatus("Starting") MachineStatusStopping = drivercore.MachineStatus("Stopping") MachineStatusCreating = drivercore.MachineStatus("Creating") )
The MachineStatus* constants add some Hyper-V specific statuses.
const ImagesVersion = "0.2"
ImagesVersion defines the image repository version for the current version of the driver.
Variables ¶
var ImagesSourceURL = "https://github.com/kuttiproject/driver-hyperv-images/releases/download/v" + ImagesVersion + "/" + imagesConfigFile
ImagesSourceURL is the location where the master list of images can be found
Functions ¶
This section is empty.
Types ¶
type Driver ¶
type Driver struct {
// contains filtered or unexported fields
}
Driver implements the drivercore.Driver interface for Hyper-V.
func (*Driver) DeleteMachine ¶
DeleteMachine completely deletes a Machine. It does this by running the Cmdlet:
Remove-VM -Name <machinename> -Force
through an interface script. It also deletes the VM disk files and the directory containing the VM files.
func (*Driver) DeleteNetwork ¶
DeleteNetwork is not implemented in the Hyper-V driver.
func (*Driver) Description ¶
Description returns "Kutti driver for Hyper-V".
func (*Driver) GetImage ¶
func (vd *Driver) GetImage(k8sversion string) (drivercore.Image, error)
GetImage returns an image corresponding to a Kubernetes version, or an error.
func (*Driver) GetMachine ¶
GetMachine returns the named machine, or an error. It does this by running the Cmdlet:
Get-VM -Name <machinename>
through an interface script.
func (*Driver) K8sVersions ¶
K8sVersions returns all Kubernetes versions currently supported.
func (*Driver) ListImages ¶
func (vd *Driver) ListImages() ([]drivercore.Image, error)
ListImages lists the currently available Images.
func (*Driver) NewMachine ¶
func (vd *Driver) NewMachine(machinename string, clustername string, k8sversion string) (drivercore.Machine, error)
NewMachine creates a VM. It also starts the VM, changes the hostname, saves the IP address, and stops it again. It uses a differencing VHDX file backed by the cached master image for the specified k8sversion in the driver cache location for VM disks. It then runs the following Cmdlets, in order:
New-VHD -Path $diffVhdPath -ParentPath $parentVhdPath -Differencing $newvm = New-VM -Name $machineName -Generation 1 -Path $machinePath -VHDPath $diffVhdPath -SwitchName "Default Switch" Set-VM $newvm -StaticMemory -MemoryStartupBytes 2147483648 -ProcessorCount 2 -CheckpointType Disabled
through an interface script.
func (*Driver) NewNetwork ¶
func (vd *Driver) NewNetwork(clustername string) (drivercore.Network, error)
NewNetwork is not implemented in the Hyper-V driver.
func (*Driver) QualifiedMachineName ¶
QualifiedMachineName returns a name in the form <username>-<clustername>-<machinename>. The <username> part is needed for this driver because Hyper-V VM names are machine-wide. It separates nodes created by different users.
func (*Driver) QualifiedNetworkName ¶
QualifiedNetworkName is not implemented in the Hyper-V driver.
func (*Driver) UpdateImageList ¶
UpdateImageList fetches the latest list of VM images from the driver source URL.
func (*Driver) UsesNATNetworking ¶
UsesNATNetworking returns false.
func (*Driver) UsesPerClusterNetworking ¶
UsesPerClusterNetworking returns false.
func (*Driver) ValidK8sVersion ¶
ValidK8sVersion returns true if the specified Kubernetes version is currently supported.
type Image ¶
Image implements the drivercore.Image interface for Hyper-V. See the imagecore package.
type Machine ¶
type Machine struct {
// contains filtered or unexported fields
}
Machine implements the drivercore.Machine interface for VirtualBox
func (*Machine) Error ¶
Error returns the last error caused when manipulating this machine. A valid value can be expected only when Status() returns drivercore.MachineStatusError.
func (*Machine) ExecuteCommand ¶
func (vh *Machine) ExecuteCommand(command drivercore.PredefinedCommand, params ...string) error
ExecuteCommand executes the specified predefined command.
func (*Machine) ForceStop ¶
ForceStop stops a Machine forcibly. It does this by running the command:
Stop-VM -Name <machinename> -TurnOff
through an interface script. This operation will set the status to drivercore.MachineStatusStopped.
func (*Machine) ForwardPort ¶
ForwardPort is not supported for the Hyper-V driver.
func (*Machine) ForwardSSHPort ¶
ForwardSSHPort is not supported for the Hyper-V driver.
func (*Machine) IPAddress ¶
IPAddress returns the current IP Address of this Machine. The Machine status has to be Running. If not, returns an empty string.
func (*Machine) ImplementsCommand ¶
func (vh *Machine) ImplementsCommand(command drivercore.PredefinedCommand) bool
ImplementsCommand returns true if the driver implements the specified predefined command. The Hyper-V driver implements drivercore.RenameMachine
func (*Machine) SSHAddress ¶
SSHAddress returns the address to SSH into this Machine. The Machine status has to be Running. If not, returns an empty string. In the Hyper-V driver, this is the same as the IP address, followed by ":22" if not blank.
func (*Machine) Start ¶
Start starts a Machine. It does this by running the command:
Start-VM -Name <machinename>
through an interface script. Note that a Machine may not be ready for further operations at the end of this, and therefore its status will Starting, not Started. See WaitForStateChange().
func (*Machine) Status ¶
func (vh *Machine) Status() drivercore.MachineStatus
Status can be drivercore.MachineStatusRunning, drivercore.MachineStatusStopped drivercore.MachineStatusUnknown, drivercore.MachineStatusError, driverhyperv.MachineStatusStarting or driverhyperv.MachineStatusStopping.
func (*Machine) Stop ¶
Stop stops a Machine. It does this by running the command:
Stop-VM -Name <machinename> -Force
Note that a Machine may not be ready for further operations at the end of this, and therefore its status will be Stopping, not Stopped. See WaitForStateChange().
func (*Machine) UnforwardPort ¶
UnforwardPort is not supported for the Hyper-V driver.
func (*Machine) WaitForStateChange ¶
WaitForStateChange waits up to the specified number of seconds, or until the Machine status changes. It does this through the waitmachine command of the interface script. If the Machine is starting, the script runs the command:
Wait-VM -ErrorAction Stop -VMName $machineName -Timeout $timeOutSeconds -For IPAddress
If the Machine is stopping, Wait-VM cannot be used, and the script looks at the state of the VM until it is Off. If the command works, the Machine is updated from its result. If it does not, for example because the time ran out, the Machine is left as it was. A timeout that is not positive is taken by the script as 25 seconds. WaitForStateChange should be called after a call to Start or Stop, before any other operation.