Documentation ¶
Index ¶
- Constants
- Variables
- func GetMostFreeDatastore(dsMo []mo.Datastore) mo.Datastore
- func GetNonCompatibleDatastoreFaultMsg(compatibilityResult pbm.PlacementCompatibilityResult, ...) string
- func GetgovmomiClient(cfg *VSphereConfig) (*govmomi.Client, error)
- type VSphere
- func (vs *VSphere) AddSSHKeyToAllInstances(user string, keyData []byte) error
- func (vs *VSphere) AttachDisk(vmDiskPath string, storagePolicyID string, nodeName k8stypes.NodeName) (diskID string, diskUUID string, err error)
- func (vs *VSphere) Clusters() (cloudprovider.Clusters, bool)
- func (vs *VSphere) CreateVolume(volumeOptions *VolumeOptions) (volumePath string, err error)
- func (vs *VSphere) CurrentNodeName(hostname string) (k8stypes.NodeName, error)
- func (vs *VSphere) DeleteVolume(vmDiskPath string) error
- func (vs *VSphere) DetachDisk(volPath string, nodeName k8stypes.NodeName) error
- func (vs *VSphere) DiskIsAttached(volPath string, nodeName k8stypes.NodeName) (bool, error)
- func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeName) (map[string]bool, error)
- func (vs *VSphere) ExternalID(nodeName k8stypes.NodeName) (string, error)
- func (vs *VSphere) GetCompatibleDatastoresMo(ctx context.Context, compatibilityResult pbm.PlacementCompatibilityResult) ([]mo.Datastore, error)
- func (vs *VSphere) GetNonCompatibleDatastoresMo(ctx context.Context, compatibilityResult pbm.PlacementCompatibilityResult) []mo.Datastore
- func (vs *VSphere) GetPlacementCompatibilityResult(ctx context.Context, pbmClient *pbm.Client, storagePolicyID string) (pbm.PlacementCompatibilityResult, error)
- func (vs *VSphere) GetVMsInsideFolder(ctx context.Context, vmFolder *object.Folder, properties []string) ([]mo.VirtualMachine, error)
- func (vs *VSphere) Initialize(clientBuilder controller.ControllerClientBuilder)
- func (vs *VSphere) InstanceID(nodeName k8stypes.NodeName) (string, error)
- func (vs *VSphere) InstanceType(name k8stypes.NodeName) (string, error)
- func (vs *VSphere) InstanceTypeByProviderID(providerID string) (string, error)
- func (vs *VSphere) Instances() (cloudprovider.Instances, bool)
- func (vs *VSphere) IsUserSpecifiedDatastoreNonCompatible(ctx context.Context, compatibilityResult pbm.PlacementCompatibilityResult, ...) (bool, *types.ManagedObjectReference)
- func (vs *VSphere) LoadBalancer() (cloudprovider.LoadBalancer, bool)
- func (vs *VSphere) NodeAddresses(nodeName k8stypes.NodeName) ([]v1.NodeAddress, error)
- func (vs *VSphere) NodeAddressesByProviderID(providerID string) ([]v1.NodeAddress, error)
- func (vs *VSphere) NodeExists(nodeName k8stypes.NodeName) (bool, error)
- func (vs *VSphere) ProviderName() string
- func (vs *VSphere) Routes() (cloudprovider.Routes, bool)
- func (vs *VSphere) ScrubDNS(nameservers, searches []string) (nsOut, srchOut []string)
- func (vs *VSphere) Zones() (cloudprovider.Zones, bool)
- type VSphereConfig
- type VolumeOptions
- type Volumes
Constants ¶
const ( ProviderName = "vsphere" ActivePowerState = "poweredOn" SCSIControllerType = "scsi" LSILogicControllerType = "lsiLogic" BusLogicControllerType = "busLogic" PVSCSIControllerType = "pvscsi" LSILogicSASControllerType = "lsiLogic-sas" SCSIControllerLimit = 4 SCSIControllerDeviceLimit = 15 SCSIDeviceSlots = 16 SCSIReservedSlot = 7 ThinDiskType = "thin" PreallocatedDiskType = "preallocated" EagerZeroedThickDiskType = "eagerZeroedThick" ZeroedThickDiskType = "zeroedThick" VolDir = "kubevols" RoundTripperDefaultCount = 3 DummyVMPrefixName = "vsphere-k8s" VSANDatastoreType = "vsan" MAC_OUI_VC = "00:50:56" MAC_OUI_ESX = "00:0c:29" DiskNotFoundErrMsg = "No vSphere disk ID found" NoDiskUUIDFoundErrMsg = "No disk UUID found" NoDevicesFoundErrMsg = "No devices found" NonSupportedControllerTypeErrMsg = "Disk is attached to non-supported controller type" FileAlreadyExistErrMsg = "File requested already exist" CleanUpDummyVMRoutine_Interval = 5 UUIDPath = "/sys/class/dmi/id/product_serial" UUIDPrefix = "VMware-" NameProperty = "name" )
const ( DatastoreProperty = "datastore" DatastoreInfoProperty = "info" Folder = "Folder" VirtualMachine = "VirtualMachine" )
Variables ¶
var DiskformatValidOptions = generateDiskFormatValidOptions()
var ErrFileAlreadyExist = errors.New(FileAlreadyExistErrMsg)
var ErrNoDevicesFound = errors.New(NoDevicesFoundErrMsg)
var ErrNoDiskIDFound = errors.New(DiskNotFoundErrMsg)
var ErrNoDiskUUIDFound = errors.New(NoDiskUUIDFoundErrMsg)
var ErrNonSupportedControllerType = errors.New(NonSupportedControllerTypeErrMsg)
Functions ¶
func GetMostFreeDatastore ¶
Get the best fit compatible datastore by free space.
func GetNonCompatibleDatastoreFaultMsg ¶
func GetNonCompatibleDatastoreFaultMsg(compatibilityResult pbm.PlacementCompatibilityResult, dsMoref types.ManagedObjectReference) string
func GetgovmomiClient ¶
func GetgovmomiClient(cfg *VSphereConfig) (*govmomi.Client, error)
Types ¶
type VSphere ¶
type VSphere struct {
// contains filtered or unexported fields
}
VSphere is an implementation of cloud provider Interface for VSphere.
func GetVSphere ¶
Reads vSphere configuration from system environment and construct vSphere object
func (*VSphere) AddSSHKeyToAllInstances ¶
func (*VSphere) AttachDisk ¶
func (vs *VSphere) AttachDisk(vmDiskPath string, storagePolicyID string, nodeName k8stypes.NodeName) (diskID string, diskUUID string, err error)
Attaches given virtual disk volume to the compute running kubelet.
func (*VSphere) CreateVolume ¶
func (vs *VSphere) CreateVolume(volumeOptions *VolumeOptions) (volumePath string, err error)
CreateVolume creates a volume of given size (in KiB).
func (*VSphere) CurrentNodeName ¶
func (*VSphere) DeleteVolume ¶
DeleteVolume deletes a volume given volume name. Also, deletes the folder where the volume resides.
func (*VSphere) DetachDisk ¶
DetachDisk detaches given virtual disk volume from the compute running kubelet.
func (*VSphere) DiskIsAttached ¶
DiskIsAttached returns if disk is attached to the VM using controllers supported by the plugin.
func (*VSphere) DisksAreAttached ¶
func (vs *VSphere) DisksAreAttached(volPaths []string, nodeName k8stypes.NodeName) (map[string]bool, error)
DisksAreAttached returns if disks are attached to the VM using controllers supported by the plugin.
func (*VSphere) ExternalID ¶
ExternalID returns the cloud provider ID of the node with the specified Name (deprecated).
func (*VSphere) GetCompatibleDatastoresMo ¶
func (*VSphere) GetNonCompatibleDatastoresMo ¶
func (*VSphere) GetPlacementCompatibilityResult ¶
func (vs *VSphere) GetPlacementCompatibilityResult(ctx context.Context, pbmClient *pbm.Client, storagePolicyID string) (pbm.PlacementCompatibilityResult, error)
Get placement compatibility result based on storage policy requirements.
func (*VSphere) GetVMsInsideFolder ¶
func (vs *VSphere) GetVMsInsideFolder(ctx context.Context, vmFolder *object.Folder, properties []string) ([]mo.VirtualMachine, error)
Get the VM list inside a folder.
func (*VSphere) Initialize ¶
func (vs *VSphere) Initialize(clientBuilder controller.ControllerClientBuilder)
Initialize passes a Kubernetes clientBuilder interface to the cloud provider
func (*VSphere) InstanceID ¶
InstanceID returns the cloud provider ID of the node with the specified Name.
func (*VSphere) InstanceType ¶
func (*VSphere) InstanceTypeByProviderID ¶
InstanceTypeByProviderID returns the cloudprovider instance type of the node with the specified unique providerID This method will not be called from the node that is requesting this ID. i.e. metadata service and other local methods cannot be used here
func (*VSphere) Instances ¶
func (vs *VSphere) Instances() (cloudprovider.Instances, bool)
Instances returns an implementation of Instances for vSphere.
func (*VSphere) IsUserSpecifiedDatastoreNonCompatible ¶
func (vs *VSphere) IsUserSpecifiedDatastoreNonCompatible(ctx context.Context, compatibilityResult pbm.PlacementCompatibilityResult, dsName string) (bool, *types.ManagedObjectReference)
Verify if the user specified datastore is in the list of non-compatible datastores. If yes, return the non compatible datastore reference.
func (*VSphere) LoadBalancer ¶
func (vs *VSphere) LoadBalancer() (cloudprovider.LoadBalancer, bool)
LoadBalancer returns an implementation of LoadBalancer for vSphere.
func (*VSphere) NodeAddresses ¶
NodeAddresses is an implementation of Instances.NodeAddresses.
func (*VSphere) NodeAddressesByProviderID ¶
func (vs *VSphere) NodeAddressesByProviderID(providerID string) ([]v1.NodeAddress, error)
NodeAddressesByProviderID returns the node addresses of an instances with the specified unique providerID This method will not be called from the node that is requesting this ID. i.e. metadata service and other local methods cannot be used here
func (*VSphere) NodeExists ¶
NodeExists checks if the node with given nodeName exist. Returns false if VM doesn't exist or VM is in powerOff state.
func (*VSphere) ProviderName ¶
ProviderName returns the cloud provider ID.
func (*VSphere) Routes ¶
func (vs *VSphere) Routes() (cloudprovider.Routes, bool)
Routes returns a false since the interface is not supported for vSphere.
type VSphereConfig ¶
type VSphereConfig struct { Global struct { // vCenter username. User string `gcfg:"user"` // vCenter password in clear text. Password string `gcfg:"password"` // vCenter IP. VCenterIP string `gcfg:"server"` // vCenter port. VCenterPort string `gcfg:"port"` // True if vCenter uses self-signed cert. InsecureFlag bool `gcfg:"insecure-flag"` // Datacenter in which VMs are located. Datacenter string `gcfg:"datacenter"` // Datastore in which vmdks are stored. Datastore string `gcfg:"datastore"` // WorkingDir is path where VMs can be found. WorkingDir string `gcfg:"working-dir"` // Soap round tripper count (retries = RoundTripper - 1) RoundTripperCount uint `gcfg:"soap-roundtrip-count"` // VMUUID is the VM Instance UUID of virtual machine which can be retrieved from instanceUuid // property in VmConfigInfo, or also set as vc.uuid in VMX file. // If not set, will be fetched from the machine via sysfs (requires root) VMUUID string `gcfg:"vm-uuid"` // VMName is the VM name of virtual machine // Combining the WorkingDir and VMName can form a unique InstanceID. // When vm-name is set, no username/password is required on worker nodes. VMName string `gcfg:"vm-name"` } Network struct { // PublicNetwork is name of the network the VMs are joined to. PublicNetwork string `gcfg:"public-network"` } Disk struct { // SCSIControllerType defines SCSI controller to be used. SCSIControllerType string `dcfg:"scsicontrollertype"` } }
type VolumeOptions ¶
type VolumeOptions struct { CapacityKB int Tags map[string]string Name string DiskFormat string Datastore string VSANStorageProfileData string StoragePolicyName string StoragePolicyID string }
VolumeOptions specifies capacity, tags, name and diskFormat for a volume.
type Volumes ¶
type Volumes interface { // AttachDisk attaches given disk to given node. Current node // is used when nodeName is empty string. AttachDisk(vmDiskPath string, storagePolicyID string, nodeName k8stypes.NodeName) (diskID string, diskUUID string, err error) // DetachDisk detaches given disk to given node. Current node // is used when nodeName is empty string. // Assumption: If node doesn't exist, disk is already detached from node. DetachDisk(volPath string, nodeName k8stypes.NodeName) error // DiskIsAttached checks if a disk is attached to the given node. // Assumption: If node doesn't exist, disk is not attached to the node. DiskIsAttached(volPath string, nodeName k8stypes.NodeName) (bool, error) // DisksAreAttached checks if a list disks are attached to the given node. // Assumption: If node doesn't exist, disks are not attached to the node. DisksAreAttached(volPath []string, nodeName k8stypes.NodeName) (map[string]bool, error) // CreateVolume creates a new vmdk with specified parameters. CreateVolume(volumeOptions *VolumeOptions) (volumePath string, err error) // DeleteVolume deletes vmdk. DeleteVolume(vmDiskPath string) error }