vsphere

package
v1.16.6 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2020 License: Apache-2.0 Imports: 48 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DatacenterType             = "Datacenter"
	ClusterComputeResourceType = "ClusterComputeResource"
	HostSystemType             = "HostSystem"
)
View Source
const (
	VolDir                    = "kubevols"
	DefaultDiskCapacityKB     = 2097152
	DefaultDiskFormat         = "thin"
	DefaultSCSIControllerType = "lsiLogic"
	VirtualMachineType        = "VirtualMachine"
)
View Source
const (
	SPBMPolicyName            = "VSPHERE_SPBM_POLICY_NAME"
	StorageClassDatastoreName = "VSPHERE_DATASTORE"
	SecondSharedDatastore     = "VSPHERE_SECOND_SHARED_DATASTORE"
	KubernetesClusterName     = "VSPHERE_KUBERNETES_CLUSTER"
	SPBMTagPolicy             = "VSPHERE_SPBM_TAG_POLICY"
)
View Source
const (
	VCPClusterDatastore        = "CLUSTER_DATASTORE"
	SPBMPolicyDataStoreCluster = "VSPHERE_SPBM_POLICY_DS_CLUSTER"
)
View Source
const (
	VCPScaleVolumeCount   = "VCP_SCALE_VOLUME_COUNT"
	VCPScaleVolumesPerPod = "VCP_SCALE_VOLUME_PER_POD"
	VCPScaleInstances     = "VCP_SCALE_INSTANCES"
)
View Source
const (
	VCPStressInstances  = "VCP_STRESS_INSTANCES"
	VCPStressIterations = "VCP_STRESS_ITERATIONS"
)
View Source
const (
	VCPPerfVolumeCount   = "VCP_PERF_VOLUME_COUNT"
	VCPPerfVolumesPerPod = "VCP_PERF_VOLUME_PER_POD"
	VCPPerfIterations    = "VCP_PERF_ITERATIONS"
)
View Source
const (
	VCPZoneVsanDatastore1      = "VCP_ZONE_VSANDATASTORE1"
	VCPZoneVsanDatastore2      = "VCP_ZONE_VSANDATASTORE2"
	VCPZoneCompatPolicyName    = "VCP_ZONE_COMPATPOLICY_NAME"
	VCPZoneNonCompatPolicyName = "VCP_ZONE_NONCOMPATPOLICY_NAME"
	VCPZoneA                   = "VCP_ZONE_A"
	VCPZoneB                   = "VCP_ZONE_B"
	VCPZoneC                   = "VCP_ZONE_C"
	VCPZoneD                   = "VCP_ZONE_D"
)
View Source
const (
	DummyDiskName  = "kube-dummyDisk.vmdk"
	ProviderPrefix = "vsphere://"
)
View Source
const (
	InvalidDatastore = "invalidDatastore"
	DatastoreSCName  = "datastoresc"
)
View Source
const (
	Ext4FSType    = "ext4"
	Ext3FSType    = "ext3"
	InvalidFSType = "ext10"
	ExecCommand   = "/bin/df -T /mnt/volume1 | /bin/awk 'FNR == 2 {print $2}' > /mnt/volume1/fstype && while true ; do sleep 2 ; done"
)
View Source
const (
	SCSIUnitsAvailablePerNode = 55
	CreateOp                  = "CreateOp"
	AttachOp                  = "AttachOp"
	DetachOp                  = "DetachOp"
	DeleteOp                  = "DeleteOp"
)
This test calculates latency numbers for volume lifecycle operations

1. Create 4 type of storage classes 2. Read the total number of volumes to be created and volumes per pod 3. Create total PVCs (number of volumes) 4. Create Pods with attached volumes per pod 5. Verify access to the volumes 6. Delete pods and wait for volumes to detach 7. Delete the PVCs

View Source
const (
	VmfsDatastore                              = "sharedVmfs-0"
	VsanDatastore                              = "vsanDatastore"
	Datastore                                  = "datastore"
	Policy_DiskStripes                         = "diskStripes"
	Policy_HostFailuresToTolerate              = "hostFailuresToTolerate"
	Policy_CacheReservation                    = "cacheReservation"
	Policy_ObjectSpaceReservation              = "objectSpaceReservation"
	Policy_IopsLimit                           = "iopsLimit"
	DiskFormat                                 = "diskformat"
	ThinDisk                                   = "thin"
	SpbmStoragePolicy                          = "storagepolicyname"
	BronzeStoragePolicy                        = "bronze"
	HostFailuresToTolerateCapabilityVal        = "0"
	CacheReservationCapabilityVal              = "20"
	DiskStripesCapabilityVal                   = "1"
	ObjectSpaceReservationCapabilityVal        = "30"
	IopsLimitCapabilityVal                     = "100"
	StripeWidthCapabilityVal                   = "2"
	DiskStripesCapabilityInvalidVal            = "14"
	HostFailuresToTolerateCapabilityInvalidVal = "4"
	DummyVMPrefixName                          = "vsphere-k8s"
	DiskStripesCapabilityMaxVal                = "11"
)
View Source
const (
	DiskSizeSCName = "disksizesc"
)
View Source
const (
	NodeLabelKey = "vsphere_e2e_label"
)

Perform vsphere volume life cycle management at scale based on user configurable value for number of volumes. The following actions will be performed as part of this test.

1. Create Storage Classes of 4 Categories (Default, SC with Non Default Datastore, SC with SPBM Policy, SC with VSAN Storage Capabilities.) 2. Read VCP_SCALE_VOLUME_COUNT, VCP_SCALE_INSTANCES, VCP_SCALE_VOLUMES_PER_POD, VSPHERE_SPBM_POLICY_NAME, VSPHERE_DATASTORE from System Environment. 3. Launch VCP_SCALE_INSTANCES goroutine for creating VCP_SCALE_VOLUME_COUNT volumes. Each goroutine is responsible for create/attach of VCP_SCALE_VOLUME_COUNT/VCP_SCALE_INSTANCES volumes. 4. Read VCP_SCALE_VOLUMES_PER_POD from System Environment. Each pod will be have VCP_SCALE_VOLUMES_PER_POD attached to it. 5. Once all the go routines are completed, we delete all the pods and volumes.

Variables

This section is empty.

Functions

func Bootstrap

func Bootstrap(fw *framework.Framework)

Bootstrap takes care of initializing necessary test context for vSphere tests

func Connect

func Connect(ctx context.Context, vs *VSphere) error

Connect makes connection to vSphere No actions are taken if a connection exists and alive. Otherwise, a new client will be created.

func GetAndExpectIntEnvVar

func GetAndExpectIntEnvVar(varName string) int

func GetAndExpectStringEnvVar

func GetAndExpectStringEnvVar(varName string) string

func GetVSphereInstances

func GetVSphereInstances() (map[string]*VSphere, error)

GetVSphereInstances parses vsphere.conf and returns VSphere instances

func NewClient

func NewClient(ctx context.Context, vs *VSphere) (*govmomi.Client, error)

NewClient creates a new client for vSphere connection

func PerformVolumeLifeCycleInParallel

func PerformVolumeLifeCycleInParallel(f *framework.Framework, client clientset.Interface, namespace string, instanceId string, sc *storagev1.StorageClass, iterations int, wg *sync.WaitGroup)

goroutine to perform volume lifecycle operations in parallel

func VolumeCreateAndAttach

func VolumeCreateAndAttach(client clientset.Interface, namespace string, sc []*storagev1.StorageClass, volumeCountPerInstance int, volumesPerPod int, nodeSelectorList []*NodeSelector, nodeVolumeMapChan chan map[string][]string)

VolumeCreateAndAttach peforms create and attach operations of vSphere persistent volumes at scale

Types

type Config

type Config struct {
	Username          string
	Password          string
	Hostname          string
	Port              string
	Datacenters       string
	RoundTripperCount uint
	DefaultDatastore  string
	Folder            string
}

Config represents vSphere configuration

type ConfigFile

type ConfigFile struct {
	Global struct {
		// vCenter username.
		User string `gcfg:"user"`
		// vCenter password in clear text.
		Password string `gcfg:"password"`
		// vCenter port.
		VCenterPort string `gcfg:"port"`
		// True if vCenter uses self-signed cert.
		InsecureFlag bool `gcfg:"insecure-flag"`
		// Datacenter in which VMs are located.
		Datacenters string `gcfg:"datacenters"`
		// Soap round tripper count (retries = RoundTripper - 1)
		RoundTripperCount uint `gcfg:"soap-roundtrip-count"`
	}

	VirtualCenter map[string]*Config

	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"`
	}

	// Endpoint used to create volumes
	Workspace struct {
		VCenterIP        string `gcfg:"server"`
		Datacenter       string `gcfg:"datacenter"`
		Folder           string `gcfg:"folder"`
		DefaultDatastore string `gcfg:"default-datastore"`
		ResourcePoolPath string `gcfg:"resourcepool-path"`
	}
}

ConfigFile represents the content of vsphere.conf file. Users specify the configuration of one or more vSphere instances in vsphere.conf where the Kubernetes master and worker nodes are running.

type NodeInfo

type NodeInfo struct {
	Name              string
	DataCenterRef     types.ManagedObjectReference
	VirtualMachineRef types.ManagedObjectReference
	HostSystemRef     types.ManagedObjectReference
	VSphere           *VSphere
	Zones             []string
}

func GetReadySchedulableNodeInfos

func GetReadySchedulableNodeInfos() []*NodeInfo

GetAllReadySchedulableNodeInfos returns NodeInfo objects for all nodes with Ready and schedulable state

func GetReadySchedulableRandomNodeInfo

func GetReadySchedulableRandomNodeInfo() *NodeInfo

GetReadySchedulableRandomNodeInfo returns NodeInfo object for one of the Ready and Schedulable Node. if multiple nodes are present with Ready and Scheduable state then one of the Node is selected randomly and it's associated NodeInfo object is returned.

type NodeMapper

type NodeMapper struct {
}

func (*NodeMapper) GenerateNodeMap

func (nm *NodeMapper) GenerateNodeMap(vSphereInstances map[string]*VSphere, nodeList v1.NodeList) error

GenerateNodeMap populates node name to node info map

func (*NodeMapper) GenerateZoneToDatastoreMap added in v1.14.0

func (nm *NodeMapper) GenerateZoneToDatastoreMap() error

Generate zone to datastore mapping for easily verifying volume placement

func (*NodeMapper) GetDatastoresInZone added in v1.14.0

func (nm *NodeMapper) GetDatastoresInZone(vc string, zone string) []string

Get all the datastores in the specified zone

func (*NodeMapper) GetNodeInfo

func (nm *NodeMapper) GetNodeInfo(nodeName string) *NodeInfo

GetNodeInfo return NodeInfo for given nodeName

func (*NodeMapper) SetNodeInfo

func (nm *NodeMapper) SetNodeInfo(nodeName string, nodeInfo *NodeInfo)

SetNodeInfo sets NodeInfo for given nodeName. This function is not thread safe. Users need to handle concurrency.

type NodeSelector

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

NodeSelector holds

type VSphere

type VSphere struct {
	Config *Config
	Client *govmomi.Client
}

Represents a vSphere instance where one or more kubernetes nodes are running.

func (*VSphere) CreateVolume

func (vs *VSphere) CreateVolume(volumeOptions *VolumeOptions, dataCenterRef types.ManagedObjectReference) (string, error)

CreateVolume creates a vsphere volume using given volume parameters specified in VolumeOptions. If volume is created successfully the canonical disk path is returned else error is returned.

func (*VSphere) DeleteVolume

func (vs *VSphere) DeleteVolume(volumePath string, dataCenterRef types.ManagedObjectReference) error

DeleteVolume deletes the vmdk file specified in the volumePath. if an error is encountered while deleting volume, error is returned.

func (*VSphere) GetAllDatacenter

func (vs *VSphere) GetAllDatacenter(ctx context.Context) ([]*object.Datacenter, error)

GetAllDatacenter returns all the DataCenter Objects

func (*VSphere) GetDatacenter

func (vs *VSphere) GetDatacenter(ctx context.Context, datacenterPath string) (*object.Datacenter, error)

GetDatacenter returns the DataCenter Object for the given datacenterPath

func (*VSphere) GetDatacenterFromObjectReference

func (vs *VSphere) GetDatacenterFromObjectReference(ctx context.Context, dc object.Reference) *object.Datacenter

GetDatacenter returns the DataCenter Object for the given datacenterPath

func (*VSphere) GetDatastoreRefFromName added in v1.14.0

func (vs *VSphere) GetDatastoreRefFromName(ctx context.Context, dc object.Reference, datastoreName string) (types.ManagedObjectReference, error)

Get the datastore reference of the specified datastore

func (*VSphere) GetDatastoresMountedOnHost added in v1.14.0

func (vs *VSphere) GetDatastoresMountedOnHost(ctx context.Context, host types.ManagedObjectReference) []types.ManagedObjectReference

Get the datastore references of all the datastores mounted on the specified host

func (*VSphere) GetFolderByPath

func (vs *VSphere) GetFolderByPath(ctx context.Context, dc object.Reference, folderPath string) (vmFolderMor types.ManagedObjectReference, err error)

GetFolderByPath gets the Folder Object Reference from the given folder path folderPath should be the full path to folder

func (*VSphere) GetHostFromVMReference added in v1.14.0

func (vs *VSphere) GetHostFromVMReference(ctx context.Context, vm types.ManagedObjectReference) types.ManagedObjectReference

Get host object reference of the host on which the specified VM resides

func (*VSphere) GetVMByUUID

func (vs *VSphere) GetVMByUUID(ctx context.Context, vmUUID string, dc object.Reference) (object.Reference, error)

GetVMByUUID gets the VM object Reference from the given vmUUID

func (*VSphere) IsVMPresent

func (vs *VSphere) IsVMPresent(vmName string, dataCenterRef types.ManagedObjectReference) (isVMPresent bool, err error)

IsVMPresent checks if VM with the name specified in the vmName argument, is present in the vCenter inventory. if VM is present, function returns true else false.

type VSphereContext

type VSphereContext struct {
	NodeMapper       *NodeMapper
	VSphereInstances map[string]*VSphere
}

Context holds common information for vSphere tests

var TestContext VSphereContext

TestContext should be used by all tests to access common context data. It should be initialized only once, during bootstrapping the tests.

type VolumeOptions

type VolumeOptions struct {
	Name               string
	CapacityKB         int
	DiskFormat         string
	SCSIControllerType string
	Datastore          string
}

VolumeOptions specifies various options for a volume.

Jump to

Keyboard shortcuts

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