provisioner

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2023 License: Apache-2.0 Imports: 41 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//KeyPVNFSServerType defines if the NFS PV should be launched
	// using kernel or ganesha
	KeyPVNFSServerType = "NFSServerType"

	//KeyPVBackendStorageClass defines default provisioner to be used
	// to create the data(export) directory for NFS server
	KeyPVBackendStorageClass = "BackendStorageClass"

	//CustomServerConfig defines the server configuration to use,
	// if it is set. Otherwise, use the default NFS server configuration.
	CustomServerConfig = "CustomServerConfig"

	// LeaseTime defines the renewal period(in seconds) for client state
	// if not set then default value(90s) will be used
	LeaseTime        = "LeaseTime"
	DefaultLeaseTime = 90

	// GraceTime defines the recovery period(in seconds) to reclaim locks
	// If it is not set then default value(90s) will be used
	GraceTime        = "GraceTime"
	DefaultGraceTime = 90

	// FSGroupID defines the permissions of nfs share volume
	// -----------------------------------------------------
	// NOTE: This feature has been deprecated
	//       Alternative: Use FilePermission 'cas.openebs.io/config' annotation
	//                    key on the backend volume PVC. Sample FilePermissions
	//      	      for FSGID-like configuration --
	//
	//                    name: FilePermissions
	//                    data:
	//                      GID: <group-ID>
	//                      mode: "g+s"
	// -----------------------------------------------------
	FSGroupID = "FSGID"

	// This is the cas-template key for all file permission 'data' keys
	FilePermissions = "FilePermissions"

	// FsUID defines the user owner of the shared directory
	FsUID = "UID"

	// FsGID defines the group owner of the shared directory
	FsGID = "GID"

	// FSMode defines the file permission mode of the shared directory
	FsMode = "mode"

	// NFSServerResourceRequests holds key name that represent NFS Resource Requests
	NFSServerResourceRequests = "NFSServerResourceRequests"

	// NFSServerResourceLimits holds key name that represent NFS Resource Limits
	NFSServerResourceLimits = "NFSServerResourceLimits"

	// HookConfigFileName represent file name for hook configuration
	HookConfigFileName = "hook-config"

	// ConfigDirectory defines directory to store config files specific to NFS provisioner
	ConfigDirectory = "/etc/nfs-provisioner"

	// HookConfigFilePath defines path for hook config file
	HookConfigFilePath = ConfigDirectory + "/" + HookConfigFileName
)
View Source
const (
	// ProvisionerNFSServerType is the environment variable that
	// allows user to specify the default NFS Server type to be used.
	ProvisionerNFSServerType menv.ENVKey = "OPENEBS_IO_NFS_SERVER_TYPE"

	// ProvisionerExportsSC is the environment variable that provides the
	// default storage class to be used for exports PVC mount used by NFS Server.
	ProvisionerExportsSC menv.ENVKey = "OPENEBS_IO_EXPORTS_SC"

	// ProvisionerNFSServerUseClusterIP is the environment variable that
	// allows user to specify if ClusterIP should be used in NFS K8s Service
	ProvisionerNFSServerUseClusterIP menv.ENVKey = "OPENEBS_IO_NFS_SERVER_USE_CLUSTERIP"

	// NFSServerImageKey is the environment variable that
	// store the container image name to be used for nfs-server deployment
	//
	// Note: If image name is not mentioned then provisioner.ProvisionerNFSServerImage
	//
	NFSServerImageKey menv.ENVKey = "OPENEBS_IO_NFS_SERVER_IMG"

	// NFSServerNamespace defines the namespace for nfs server objects
	// Default value is menv.OpenEBSNamespace(operator namespace)
	NFSServerNamespace menv.ENVKey = "OPENEBS_IO_NFS_SERVER_NS"

	// NodeAffinityKey holds the env name representing Node affinity rules
	NodeAffinityKey menv.ENVKey = "OPENEBS_IO_NFS_SERVER_NODE_AFFINITY"

	// NFSBackendPvcTimeout defines env name to store BackendPvcBoundTimeout value
	NFSBackendPvcTimeout menv.ENVKey = "OPENEBS_IO_NFS_SERVER_BACKEND_PVC_TIMEOUT"

	// The NFSGarbageCollectionEnable environment variable is the switch for the garbage collector.(default true)
	NFSGarbageCollectionEnable menv.ENVKey = "OPENEBS_IO_NFS_SERVER_GARBAGE_COLLECTION_ENABLED"

	// NFSServerImagePullSecret defines the env name to store the name of the image pull secret
	NFSServerImagePullSecret menv.ENVKey = "OPENEBS_IO_NFS_SERVER_IMAGE_PULL_SECRET"
)
View Source
const (

	// NFSPVFinalizer represents finalizer string used by NFSPV
	NFSPVFinalizer = "nfs.openebs.io/finalizer"

	//NFSServerPort set the NFS Server Port
	NFSServerPort = 2049

	//RPCBindPort set the RPC Bind Port
	RPCBindPort = 111

	// DefaultBackendPvcBoundTimeout defines the timeout for PVC Bound check.
	// set to 60 seconds
	DefaultBackendPvcBoundTimeout = 60
)
View Source
const (
	// Ping message
	Ping string = "ping"
	// DefaultCASType Event application name constant for volume event
	DefaultCASType string = "nfs"
	// Default replica count unknown action
	DefaultUnknownReplicaCount string = "replica:<N/A>"
)

Variables

View Source
var (
	// GarbageCollectorInterval defines periodic interval to run garbage collector
	GarbageCollectorInterval = 5 * time.Minute
)
View Source
var (

	// LeaderElectionKey represents ENV for disable/enable leaderElection for
	// nfs provisioner
	LeaderElectionKey = "LEADER_ELECTION_ENABLED"
)
View Source
var (

	// NFSServerDefaultImage specifies the image name to be used in
	// nfs server deployment. If image name is mentioned as a env variable
	// provisioner.NFSServerImageKey then value from env variable will be used
	NFSServerDefaultImage string
)
View Source
var (
	NodeAffinityRulesMismatchEvent = "No matching nodes found for given affinity rules"
)
View Source
var (
	//WaitForNFSServerRetries specifies the number of times provisioner
	// should wait and check if the NFS server is initialized.
	//The duration is the value specified here multiplied by 5
	WaitForNFSServerRetries = 12
)

Functions

func GetEngineName added in v0.11.0

func GetEngineName(volType, method string) string

Wrapper for setting the default storage-engine for volume-provision event

func GetNFSServerTypeFromPV

func GetNFSServerTypeFromPV(pv *v1.PersistentVolume) string

GetNFSServerTypeFromPV extracts the NFS Server Type name from PV

func GetStorageClassNameFromPVC

func GetStorageClassNameFromPVC(pvc *v1.PersistentVolumeClaim) *string

GetStorageClassNameFromPVC extracts the StorageClass name from PVC

func RegisterShutdownChannel

func RegisterShutdownChannel(cancelFn context.CancelFunc)

RegisterShutdownChannel closes the channel when signaled for termination

func RunGarbageCollector added in v0.6.0

func RunGarbageCollector(ctx context.Context, client kubernetes.Interface, pvTracker ProvisioningTracker, ns string)

func Start

func Start(ctx context.Context) error

Start will initialize and run the dynamic provisioner daemon

Types

type GetVolumeConfigFn

type GetVolumeConfigFn func(pvName string, pvc *corev1.PersistentVolumeClaim) (*VolumeConfig, error)

GetVolumeConfigFn allows to plugin a custom function

and makes it easy to unit test provisioner

type KernelNFSServerOptions

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

KernelNFSServerOptions contains the options that will launch Kernel NFS Server using the provided storage class

type NodeAffinity added in v0.5.0

type NodeAffinity struct {
	// A list of node selector requirements by node's labels
	MatchExpressions []corev1.NodeSelectorRequirement
}

NodeAffinity represents group of node affinity scheduling rules that will be applied on NFS Server instance. If it is not configured then matches to no object i.e NFS Server can schedule on any node in a cluster. Configured values will be propogated to deployment.spec.template.spec.affinity.nodeAffinity.

requiredDuringSchedulingIgnoredDuringExecution

Values are propagated via ENV(NodeAffinity) on NFS Provisioner. Example: Following can be various options to specify NodeAffinity rules

		Config 1: Configure across zones and also storage should be available
			Env Value: "kubernetes.io/hostName:[z1-host1,z2-host1,z3-host1],kubernetes.io/storage:[available]"

 		Config 1 will be propogated as shown below on NFS-Server deployment
 			nodeSelectorTerms:
 			- matchExpressions:
 			  - key: kubernetes.io/hostName
 				operator: "In"
 			    values:
 			    - z1-host1
 				- z2-host2
 				- z3-host3
 			  - key: kubernetes.io/storage
 			    operator: "In"
 				values:
 				- available

     Config2: Configure on storage nodes in zone1
			Env Value: "kubernetes.io/storage:[],kubernetes.io/zone:[zone1]"

 		Config2 will be propogated as shown below on NFS-Server deployment
 			nodeSelectorTerms:
 			- matchExpressions:
 			  - key: kubernetes.io/storage
 			    operator: "Exists"
 			  - key: kubernetes.io/zone
 				operator: "In"
 			    values:
 			    - zone1

		Configi3: Configure on any storage node
			Env Value: "kubernetes.io/storage:[]"

 		Config3 will be propogated as below on NFS-Server deployment
 			nodeSelectorTerms:
 			- matchExpressions:
 			  - key: kubernetes.io/storage
 			    operator: "Exists"

     Like shown above various combinations can be specified and before
		provisioning configuration will be validated

NOTE: All the comma separated specification will be ANDed

type Provisioner

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

Provisioner struct has the configuration and utilities required across the different work-flows.

func NewProvisioner

func NewProvisioner(ctx context.Context, kubeClient *clientset.Clientset) (*Provisioner, error)

NewProvisioner will create a new Provisioner object and initialize

it with global information used across PV create and delete operations.

func (*Provisioner) Delete

func (p *Provisioner) Delete(ctx context.Context, pv *v1.PersistentVolume) (err error)

Delete is invoked by the PVC controller to perform clean-up

activities before deleteing the PV object. If reclaim policy is
set to not-retain, then this function will create a helper pod
to delete the host path from the node.

func (*Provisioner) DeleteKernalNFSServer

func (p *Provisioner) DeleteKernalNFSServer(ctx context.Context, pv *v1.PersistentVolume) (err error)

DeleteKernalNFSServer is invoked by the PVC controller to perform clean-up

activities before deleteing the PV object. If reclaim policy is
set to not-retain, then this function will delete the associated BDC

func (*Provisioner) GetVolumeConfig

func (p *Provisioner) GetVolumeConfig(pvName string, pvc *v1.PersistentVolumeClaim) (*VolumeConfig, error)

GetVolumeConfig creates a new VolumeConfig struct by parsing and merging the configuration provided in the PVC annotation - cas.openebs.io/config with the default configuration of the provisioner.

func (*Provisioner) Provision

Provision is invoked by the PVC controller which expect the PV

to be provisioned and a valid PV spec returned.

func (*Provisioner) ProvisionKernalNFSServer

func (p *Provisioner) ProvisionKernalNFSServer(ctx context.Context, opts pvController.ProvisionOptions, volumeConfig *VolumeConfig) (*v1.PersistentVolume, error)

ProvisionKernalNFSServer is invoked by the Provisioner to create a NFS

with kernel NFS server

func (*Provisioner) SupportsBlock

func (p *Provisioner) SupportsBlock() bool

SupportsBlock will be used by controller to determine if block mode is

supported by the host path provisioner.

type ProvisioningTracker added in v0.6.0

type ProvisioningTracker interface {
	// Add PV for which provisioning is in-progress
	Add(pvName string)

	// Delete PV for which provisioning is completed
	Delete(pvName string)

	// Inprogress checks if provisioning for given PV is in-progress or not
	Inprogress(pvName string) bool
}

ProvisioningTracker tracks provisioning request

func NewProvisioningTracker added in v0.6.0

func NewProvisioningTracker() ProvisioningTracker

type VolumeConfig

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

VolumeConfig struct contains the merged configuration of the PVC and the associated SC. The configuration is derived from the annotation `cas.openebs.io/config`. The configuration will be in the following json format:

{
  Key1:{
	enabled: true
	value: "string value"
  },
  Key2:{
	enabled: true
	value: "string value"
  },
}

func (*VolumeConfig) GetBackendStorageClassFromConfig

func (c *VolumeConfig) GetBackendStorageClassFromConfig() string

GetBackendStorageClassFromConfig returns the Storage Class value configured in StorageClass. Default is ""

func (*VolumeConfig) GetCustomNFSServerConfig added in v0.3.0

func (c *VolumeConfig) GetCustomNFSServerConfig() string

func (*VolumeConfig) GetFSGroupID added in v0.5.0

func (c *VolumeConfig) GetFSGroupID() (*int64, error)

GetFSGroupID fetches the group ID permissions from StorageClass if specified ----------------------------------------------------- NOTE: This feature has been deprecated

 Alternative: Use FilePermission 'cas.openebs.io/config' annotation
              key on the backend volume PVC. Sample FilePermissions
	      for FSGID-like configuration --

              name: FilePermissions
              data:
                GID: <group-ID>
                mode: "g+s"

-----------------------------------------------------

func (*VolumeConfig) GetFsGID added in v0.9.0

func (c *VolumeConfig) GetFsGID() (string, error)

GetFsGID fetches the group owner's ID from PVC annotation, if specified

func (*VolumeConfig) GetFsMode added in v0.9.0

func (c *VolumeConfig) GetFsMode() (string, error)

GetFsMode fetches the file mode from PVC or StorageClass annotation, if specified

func (*VolumeConfig) GetFsUID added in v0.9.0

func (c *VolumeConfig) GetFsUID() string

GetFsGID fetches the user owner's ID from PVC annotation, if specified

func (*VolumeConfig) GetNFSServerLeaseTime added in v0.4.0

func (c *VolumeConfig) GetNFSServerLeaseTime() (int, error)

func (*VolumeConfig) GetNFSServerResourceRequirements added in v0.6.1

func (c *VolumeConfig) GetNFSServerResourceRequirements() (*v1.ResourceRequirements, error)

GetNFSServerResourceRequirements fetches the resource(cpu & memory) request & limits for NFS server from StorageClass only if specified

func (*VolumeConfig) GetNFSServerTypeFromConfig

func (c *VolumeConfig) GetNFSServerTypeFromConfig() string

GetNFSServerTypeFromConfig returns the NFSServerType value configured in StorageClass. Default is kernel

func (*VolumeConfig) GetNFServerGraceTime added in v0.4.0

func (c *VolumeConfig) GetNFServerGraceTime() (int, error)

Jump to

Keyboard shortcuts

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