Documentation ¶
Index ¶
- Constants
- Variables
- func FromEnv(ctx context.Context, cfg *Config) error
- func FromEnvToGC(ctx context.Context, cfg *Config) error
- func GetClusterFlavor(ctx context.Context) (cnstypes.CnsClusterFlavor, error)
- func GetSupervisorNamespace(ctx context.Context) (string, error)
- type Config
- type ConfigurationInfo
- type FeatureStatesConfigInfo
- type GCConfig
- type NetPermissionConfig
- type SnapshotConfig
- type TopologyCategoryInfo
- type VirtualCenterConfig
Constants ¶
const ( // DefaultVCenterPort is the default port used to access vCenter. DefaultVCenterPort string = "443" // DefaultGCPort is the default port used to access Supervisor Cluster. DefaultGCPort string = "6443" // DefaultCloudConfigPath is the default path of csi config file. DefaultCloudConfigPath = "/etc/cloud/csi-vsphere.conf" // DefaultGCConfigPath is the default path of GC config file. DefaultGCConfigPath = "/etc/cloud/pvcsi-config/cns-csi.conf" // SupervisorCAFilePath is the file path of certificate in Supervisor // Clusters. This is needed to establish VC connection. SupervisorCAFilePath = "/etc/vmware/wcp/tls/vmca.pem" // EnvVSphereCSIConfig contains the path to the CSI vSphere Config. EnvVSphereCSIConfig = "VSPHERE_CSI_CONFIG" // EnvGCConfig contains the path to the CSI GC Config. EnvGCConfig = "GC_CONFIG" // DefaultpvCSIProviderPath is the default path of pvCSI provider config. DefaultpvCSIProviderPath = "/etc/cloud/pvcsi-provider" // DefaultSupervisorFSSConfigMapName is the default name of Feature states // config map in Supervisor cluster. This configmap is also replicated by // the supervisor unto any TKGS deployed on it. DefaultSupervisorFSSConfigMapName = "csi-feature-states" // DefaultInternalFSSConfigMapName is the default name of feature states // config map used in pvCSI and Vanilla drivers. DefaultInternalFSSConfigMapName = "internal-feature-states.csi.vsphere.vmware.com" // DefaultCSINamespace is the default namespace for CNS-CSI and pvCSI drivers. DefaultCSINamespace = "vmware-system-csi" // DefaultCnsRegisterVolumesCleanupIntervalInMin is the default time // interval after which successful CnsRegisterVolumes will be cleaned up. // Current default value is set to 12 hours DefaultCnsRegisterVolumesCleanupIntervalInMin = 720 // DefaultVolumeMigrationCRCleanupIntervalInMin is the default time interval // after which stale CnsVSphereVolumeMigration CRs will be cleaned up. // Current default value is set to 2 hours. DefaultVolumeMigrationCRCleanupIntervalInMin = 120 // DefaultCSIAuthCheckIntervalInMin is the default time interval to refresh // DatastoreMap. DefaultCSIAuthCheckIntervalInMin = 5 // DefaultCSIFetchPreferredDatastoresIntervalInMin is the default time interval // after which the preferred datastores list is refreshed in the driver. DefaultCSIFetchPreferredDatastoresIntervalInMin = 5 // DefaultCnsVolumeOperationRequestCleanupIntervalInMin is the default time // interval after which stale CnsVSphereVolumeMigration CRs will be cleaned up. // Current default value is set to 24 hours. DefaultCnsVolumeOperationRequestCleanupIntervalInMin = 1440 // DefaultGlobalMaxSnapshotsPerBlockVolume is the default maximum number of block volume snapshots per volume. DefaultGlobalMaxSnapshotsPerBlockVolume = 3 // MaxNumberOfTopologyCategories is the max number of topology domains/categories allowed. MaxNumberOfTopologyCategories = 5 // TopologyLabelsDomain is the domain name used to identify user-defined // topology labels applied on the node by vSphere CSI driver. TopologyLabelsDomain = "topology.csi.vmware.com" // DefaultQueryLimit is the default number of volumes to be fetched from CNS QueryAll API // Current default value is set to 10000 DefaultQueryLimit = 10000 // DefaultListVolumeThreshold specifies the default maximum number of differences in volumes between CNS // and kubernetes DefaultListVolumeThreshold = 50 // TKCKind refers to the kind of TKC cluster being used. TKCKind = "TanzuKubernetesCluster" // TKCAPIVersion refers to the version of TanzuKubernetesCluster object currently being used. TKCAPIVersion = "run.tanzu.vmware.com/v1alpha1" )
Variables ¶
var ( // ErrUsernameMissing is returned when the provided username is empty. ErrUsernameMissing = errors.New("username is missing") // ErrPasswordMissing is returned when the provided password is empty. ErrPasswordMissing = errors.New("password is missing") // ErrInvalidVCenterIP is returned when the provided vCenter IP address is // missing from the provided configuration. ErrInvalidVCenterIP = errors.New("vsphere.conf does not have the VirtualCenter IP address specified") // ErrMissingVCenter is returned when the provided configuration does not // define any vCenters. ErrMissingVCenter = errors.New("no Virtual Center hosts defined") // ErrClusterIDCharLimit is returned when the provided cluster id is more // than 64 characters. ErrClusterIDCharLimit = errors.New("cluster id must not exceed 64 characters") // ErrSupervisorIDCharLimit is returned when the provided supervisor id is more // than 64 characters. ErrSupervisorIDCharLimit = errors.New("supervisor id must not exceed 64 characters") // ErrMissingEndpoint is returned when the provided configuration does not // define any endpoints. ErrMissingEndpoint = errors.New("no Supervisor Cluster endpoint defined in Guest Cluster config") // ErrMissingTanzuKubernetesClusterUID is returned when the provided // configuration does not define any TanzuKubernetesClusterUID. ErrMissingTanzuKubernetesClusterUID = errors.New("no Tanzu Kubernetes Cluster UID defined in Guest Cluster config") // ErrInvalidNetPermission is returned when the value of Permission in // NetPermissions is not among the ones listed. ErrInvalidNetPermission = errors.New("invalid value for Permissions under NetPermission Config") )
Errors
Functions ¶
func FromEnv ¶
FromEnv initializes the provided configuration object with values obtained from environment variables. If an environment variable is set for a property that's already initialized, the environment variable's value takes precedence.
func FromEnvToGC ¶
FromEnvToGC initializes the provided configuration object with values obtained from environment variables. If an environment variable is set for a property that's already initialized, the environment variable's value takes precedence.
func GetClusterFlavor ¶
func GetClusterFlavor(ctx context.Context) (cnstypes.CnsClusterFlavor, error)
GetClusterFlavor returns the cluster flavor based on the env variable set in the driver deployment file.
Types ¶
type Config ¶
type Config struct { Global struct { //vCenter IP address or FQDN VCenterIP string // Kubernetes Cluster ID ClusterID string `gcfg:"cluster-id"` // SupervisorID is the UUID representing Supervisor Cluster. ClusterID is being deprecated // and SupervisorID is the replacement ID we need to use for VolumeMetadata and datastore lookup. SupervisorID string `gcfg:"supervisor-id"` // vCenter username. User string `gcfg:"user"` // vCenter password in clear text. Password string `gcfg:"password"` // vCenter port. VCenterPort string `gcfg:"port"` // Specifies whether to verify the server's certificate chain. Set to true to // skip verification. InsecureFlag bool `gcfg:"insecure-flag"` // Specifies the path to a CA certificate in PEM format. This has no effect if // InsecureFlag is enabled. Optional; if not configured, the system's CA // certificates will be used. CAFile string `gcfg:"ca-file"` // Thumbprint specifies the certificate thumbprint to use // This has no effect if InsecureFlag is enabled. Thumbprint string `gcfg:"thumbprint"` // Datacenter in which Node VMs are located. Datacenters string `gcfg:"datacenters"` // CnsRegisterVolumesCleanupIntervalInMin specifies the interval after which // successful CnsRegisterVolumes will be cleaned up. CnsRegisterVolumesCleanupIntervalInMin int `gcfg:"cnsregistervolumes-cleanup-intervalinmin"` // VolumeMigrationCRCleanupIntervalInMin specifies the interval after which // stale CnsVSphereVolumeMigration CRs will be cleaned up. VolumeMigrationCRCleanupIntervalInMin int `gcfg:"volumemigration-cr-cleanup-intervalinmin"` // VCClientTimeout specifies a time limit in minutes for requests made by client // If not set, default will be 5 minutes VCClientTimeout int `gcfg:"vc-client-timeout"` // Cluster Distribution Name ClusterDistribution string `gcfg:"cluster-distribution"` //CSIAuthCheckIntervalInMin specifies the interval that the auth check for datastores will be trigger CSIAuthCheckIntervalInMin int `gcfg:"csi-auth-check-intervalinmin"` // CnsVolumeOperationRequestCleanupIntervalInMin specifies the interval after which // stale CnsVolumeOperationRequest instances will be cleaned up. CnsVolumeOperationRequestCleanupIntervalInMin int `gcfg:"cnsvolumeoperationrequest-cleanup-intervalinmin"` // CSIFetchPreferredDatastoresIntervalInMin specifies the interval // after which the preferred datastores cache is refreshed in the driver. CSIFetchPreferredDatastoresIntervalInMin int `gcfg:"csi-fetch-preferred-datastores-intervalinmin"` // QueryLimit specifies the number of volumes that can be fetched by CNS QueryAll API at a time QueryLimit int `gcfg:"query-limit"` // ListVolumeThreshold specifies the maximum number of differences in volume that can exist between CNS // and kubernetes ListVolumeThreshold int `gcfg:"list-volume-threshold"` } // Multiple sets of Net Permissions applied to all file shares // The string can uniquely represent each Net Permissions config NetPermissions map[string]*NetPermissionConfig // Virtual Center configurations VirtualCenter map[string]*VirtualCenterConfig // Snapshot configurations. Snapshot SnapshotConfig // Guest Cluster configurations, only used by GC GC GCConfig // Labels will list the topology domains the CSI driver is expected // to pick up from the inventory. This info will later be used while provisioning volumes. Labels struct { // Zone and Region correspond to the vSphere categories // created to tag specific topology domains in the inventory. Zone string `gcfg:"zone"` // Deprecated Region string `gcfg:"region"` // Deprecated // TopologyCategories is a comma separated string of topology domains // which will correspond to the `Categories` the vSphere admin will // create in the inventory using the UI. // Maximum number of categories allowed is 5. TopologyCategories string `gcfg:"topology-categories"` } TopologyCategory map[string]*TopologyCategoryInfo }
Config is used to read and store information from the cloud configuration file
func GetCnsconfig ¶
GetCnsconfig returns Config from specified config file path.
func GetGCconfig ¶
GetGCconfig returns Config from specified config file path.
func ReadConfig ¶
ReadConfig parses vSphere cloud config file and stores it into VSphereConfig. Environment variables are also checked.
type ConfigurationInfo ¶
type ConfigurationInfo struct {
Cfg *Config
}
ConfigurationInfo is a struct that used to capture config param details
type FeatureStatesConfigInfo ¶
FeatureStatesConfigInfo contains the details about feature states configmap
type GCConfig ¶
type GCConfig struct { // Supervisor Cluster server IP Endpoint string `gcfg:"endpoint"` // Supervisor Cluster server port Port string `gcfg:"port"` // Guest Cluster UID TanzuKubernetesClusterUID string `gcfg:"tanzukubernetescluster-uid"` // Guest Cluster Name TanzuKubernetesClusterName string `gcfg:"tanzukubernetescluster-name"` // Cluster Distribution Name ClusterDistribution string `gcfg:"cluster-distribution"` // ClusterAPIVersion refers to the API version of the object guest cluster is created from. ClusterAPIVersion string `gcfg:"cluster-api-version"` // ClusterKind refers to the kind of object guest cluster is created from. ClusterKind string `gcfg:"cluster-kind"` }
GCConfig contains information used by guest cluster to access a supervisor cluster endpoint
type NetPermissionConfig ¶
type NetPermissionConfig struct { // Client IP address, IP range or IP subnet. Example: "10.20.30.0/24"; defaults to "*" if not specified Ips string `gcfg:"ips"` // Is it READ_ONLY, READ_WRITE or NO_ACCESS. Defaults to "READ_WRITE" if not specified Permissions vsanfstypes.VsanFileShareAccessType `gcfg:"permissions"` // Disallow root access for this IP range. Defaults to "false" if not specified RootSquash bool `gcfg:"rootsquash"` }
NetPermissionConfig consists of information used to restrict the network permissions set on file share volumes
func GetDefaultNetPermission ¶
func GetDefaultNetPermission() *NetPermissionConfig
GetDefaultNetPermission returns the default file share net permission.
type SnapshotConfig ¶
type SnapshotConfig struct { // GlobalMaxSnapshotsPerBlockVolume specifies the maximum number of block volume snapshots per volume. GlobalMaxSnapshotsPerBlockVolume int `gcfg:"global-max-snapshots-per-block-volume"` // GranularMaxSnapshotsPerBlockVolumeInVSAN specifies the maximum number of block volume snapshots // per volume in VSAN datastores. GranularMaxSnapshotsPerBlockVolumeInVSAN int `gcfg:"granular-max-snapshots-per-block-volume-vsan"` // GranularMaxSnapshotsPerBlockVolumeInVVOL specifies the maximum number of block volume snapshots // per volume in VVOL datastores. GranularMaxSnapshotsPerBlockVolumeInVVOL int `gcfg:"granular-max-snapshots-per-block-volume-vvol"` }
SnapshotConfig contains snapshot configuration.
type TopologyCategoryInfo ¶ added in v2.4.1
type TopologyCategoryInfo struct {
Label string `gcfg:"label"`
}
TopologyCategoryInfo contains metadata for the Zone and Region parameters under Labels section.
type VirtualCenterConfig ¶
type VirtualCenterConfig 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"` TargetvSANFileShareDatastoreURLs string `gcfg:"targetvSANFileShareDatastoreURLs"` TargetvSANFileShareClusters string `gcfg:"targetvSANFileShareClusters"` }
VirtualCenterConfig contains information used to access a remote vCenter endpoint.