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 GetConfigPath(ctx context.Context) string
- func GetSessionUserAgent(ctx context.Context) (string, error)
- func GetSupervisorNamespace(ctx context.Context) (string, error)
- type Config
- func GetCnsconfig(ctx context.Context, cfgPath string) (*Config, error)
- func GetConfig(ctx context.Context) (*Config, error)
- func GetGCconfig(ctx context.Context, cfgPath string) (*Config, error)
- func ReadConfig(ctx context.Context, config io.Reader) (*Config, error)
- func ReadGCConfig(ctx context.Context, config io.Reader) (*Config, error)
- 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" // ClusterIDConfigMapName refers to the name of the immutable ConfigMap used to store cluster ID ClusterIDConfigMapName = "vsphere-csi-cluster-id" )
const EnvClusterFlavor = "CLUSTER_FLAVOR"
EnvClusterFlavor is the k8s cluster type on which CSI Driver is being deployed
Variables ¶
var ( // ErrUsernameMissing is returned when the provided username is empty. ErrUsernameMissing = errors.New("username is missing") // ErrInvalidUsername is returned when vCenter username provided in vSphere config // secret is invalid. e.g. If username is not a fully qualified domain name, then // it will be considered as invalid username. ErrInvalidUsername = errors.New("username is invalid, make sure it is a fully qualified domain username") // 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") // ErrMissingTopologyCategoriesForMultiVCenterSetup is returned when the TopologyCategories are not specified for // Multi vCenter deployment ErrMissingTopologyCategoriesForMultiVCenterSetup = errors.New("vsphere CSI config requires " + "topology-categories to be specified for multi vCenter deployment") // ErrMaxVCenterSupportedForMultiVCenterSetup is returned when vSphere config secret has more than 5 vCenter // servers ErrMaxVCenterSupportedForMultiVCenterSetup = errors.New("max 5 vCenters are supported for multi " + "vCenter deployment") )
Errors
var GeneratedVanillaClusterID string
GeneratedVanillaClusterID is used to save unique cluster ID generated internally when clusterID is not provided by user in vSphere config secret for vanilla k8s deployments. Scope of this variable is limited to csi-controller container, we are using wrapper function in syncer container to get the internally generated cluster ID.
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.
func GetConfigPath ¶
GetConfigPath returns ConfigPath depending on the environment variable specified and the cluster flavor set.
func GetSessionUserAgent ¶ added in v3.1.0
GetSessionUserAgent returns clusterwise unique useragent
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"` // 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
func InitConfigInfo ¶
func InitConfigInfo(ctx context.Context) (*ConfigurationInfo, error)
InitConfigInfo initializes the ConfigurationInfo struct.
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 ¶
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"` // 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 VMs are located. Datacenters string `gcfg:"datacenters"` TargetvSANFileShareClusters string `gcfg:"targetvSANFileShareClusters"` // MigrationDataStore specifies datastore which is set as default datastore in legacy cloud-config // and hence should be used as default datastore. MigrationDataStoreURL string `gcfg:"migration-datastore-url"` }
VirtualCenterConfig contains information used to access a remote vCenter endpoint.