volume

package
v1.14.5 Latest Latest
Warning

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

Go to latest
Published: Aug 1, 2019 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package volume includes internal representations of external volume types as well as utility methods required to mount/unmount volumes to kubelets.

Index

Constants

View Source
const (
	// ErrCodeNotSupported code for NotSupported Errors.
	ErrCodeNotSupported int = iota + 1
	ErrCodeNoPathDefined
	ErrCodeFsInfoFailed
)
View Source
const (
	// Common parameter which can be specified in StorageClass to specify the desired FSType
	// Provisioners SHOULD implement support for this if they are block device based
	// Must be a filesystem type supported by the host operating system.
	// Ex. "ext4", "xfs", "ntfs". Default value depends on the provisioner
	VolumeParameterFSType = "fstype"

	ProbeAddOrUpdate ProbeOperation = 1 << iota
	ProbeRemove
	CSIVolumeStaged    CSIVolumePhaseType = "staged"
	CSIVolumePublished CSIVolumePhaseType = "published"
)

Variables

This section is empty.

Functions

func IsNotSupported added in v1.5.0

func IsNotSupported(err error) bool

IsNotSupported returns true if and only if err is "key" not found error.

func NewPersistentVolumeRecyclerPodTemplate added in v1.1.0

func NewPersistentVolumeRecyclerPodTemplate() *v1.Pod

NewPersistentVolumeRecyclerPodTemplate creates a template for a recycler pod. By default, a recycler pod simply runs "rm -rf" on a volume and tests for emptiness. Most attributes of the template will be correct for most plugin implementations. The following attributes can be overridden per plugin via configuration:

  1. pod.Spec.Volumes[0].VolumeSource must be overridden. Recycler implementations without a valid VolumeSource will fail.
  2. pod.GenerateName helps distinguish recycler pods by name. Recommended. Default is "pv-recycler-".
  3. pod.Spec.ActiveDeadlineSeconds gives the recycler pod a maximum timeout before failing. Recommended. Default is 60 seconds.

See HostPath and NFS for working recycler examples

func SetVolumeOwnership added in v1.2.0

func SetVolumeOwnership(mounter Mounter, fsGroup *int64) error

SetVolumeOwnership modifies the given volume to be owned by fsGroup, and sets SetGid so that newly created files are owned by fsGroup. If fsGroup is nil nothing is done.

func ValidateRecyclerPodTemplate added in v1.6.0

func ValidateRecyclerPodTemplate(pod *v1.Pod) error

Check validity of recycle pod template List of checks: - at least one volume is defined in the recycle pod template If successful, returns nil if unsuccessful, returns an error.

Types

type AttachDetachVolumeHost added in v1.14.0

type AttachDetachVolumeHost interface {
	// CSINodeLister returns the informer lister for the CSINode API Object
	CSINodeLister() storagelisters.CSINodeLister

	// CSIDriverLister returns the informer lister for the CSIDriver API Object
	CSIDriverLister() storagelisters.CSIDriverLister

	// IsAttachDetachController is an interface marker to strictly tie AttachDetachVolumeHost
	// to the attachDetachController
	IsAttachDetachController() bool
}

AttachDetachVolumeHost is a AttachDetach Controller specific interface that plugins can use to access methods on the Attach Detach Controller.

type AttachableVolumePlugin added in v1.2.0

type AttachableVolumePlugin interface {
	DeviceMountableVolumePlugin
	NewAttacher() (Attacher, error)
	NewDetacher() (Detacher, error)
	// CanAttach tests if provided volume spec is attachable
	CanAttach(spec *Spec) bool
}

AttachableVolumePlugin is an extended interface of VolumePlugin and is used for volumes that require attachment to a node before mounting.

type Attacher added in v1.2.0

type Attacher interface {
	DeviceMounter

	// Attaches the volume specified by the given spec to the node with the given Name.
	// On success, returns the device path where the device was attached on the
	// node.
	Attach(spec *Spec, nodeName types.NodeName) (string, error)

	// VolumesAreAttached checks whether the list of volumes still attached to the specified
	// node. It returns a map which maps from the volume spec to the checking result.
	// If an error is occurred during checking, the error will be returned
	VolumesAreAttached(specs []*Spec, nodeName types.NodeName) (map[*Spec]bool, error)

	// WaitForAttach blocks until the device is attached to this
	// node. If it successfully attaches, the path to the device
	// is returned. Otherwise, if the device does not attach after
	// the given timeout period, an error will be returned.
	WaitForAttach(spec *Spec, devicePath string, pod *v1.Pod, timeout time.Duration) (string, error)
}

Attacher can attach a volume to a node.

type Attributes added in v1.2.0

type Attributes struct {
	ReadOnly        bool
	Managed         bool
	SupportsSELinux bool
}

Attributes represents the attributes of this mounter.

type BlockVolume added in v1.9.0

type BlockVolume interface {
	// GetGlobalMapPath returns a global map path which contains
	// symbolic links associated to a block device.
	// ex. plugins/kubernetes.io/{PluginName}/{DefaultKubeletVolumeDevicesDirName}/{volumePluginDependentPath}/{pod uuid}
	GetGlobalMapPath(spec *Spec) (string, error)
	// GetPodDeviceMapPath returns a pod device map path
	// and name of a symbolic link associated to a block device.
	// ex. pods/{podUid}}/{DefaultKubeletVolumeDevicesDirName}/{escapeQualifiedPluginName}/{volumeName}
	GetPodDeviceMapPath() (string, string)
}

BlockVolume interface provides methods to generate global map path and pod device map path.

type BlockVolumeMapper added in v1.9.0

type BlockVolumeMapper interface {
	BlockVolume
	// SetUpDevice prepares the volume to a self-determined directory path,
	// which may or may not exist yet and returns combination of physical
	// device path of a block volume and error.
	// If the plugin is non-attachable, it should prepare the device
	// in /dev/ (or where appropriate) and return unique device path.
	// Unique device path across kubelet node reboot is required to avoid
	// unexpected block volume destruction.
	// If the plugin is attachable, it should not do anything here,
	// just return empty string for device path.
	// Instead, attachable plugin have to return unique device path
	// at attacher.Attach() and attacher.WaitForAttach().
	// This may be called more than once, so implementations must be idempotent.
	SetUpDevice() (string, error)

	// Map maps the block device path for the specified spec and pod.
	MapDevice(devicePath, globalMapPath, volumeMapPath, volumeMapName string, podUID types.UID) error
}

BlockVolumeMapper interface provides methods to set up/map the volume.

type BlockVolumePlugin added in v1.9.0

type BlockVolumePlugin interface {
	VolumePlugin
	// NewBlockVolumeMapper creates a new volume.BlockVolumeMapper from an API specification.
	// Ownership of the spec pointer in *not* transferred.
	// - spec: The v1.Volume spec
	// - pod: The enclosing pod
	NewBlockVolumeMapper(spec *Spec, podRef *v1.Pod, opts VolumeOptions) (BlockVolumeMapper, error)
	// NewBlockVolumeUnmapper creates a new volume.BlockVolumeUnmapper from recoverable state.
	// - name: The volume name, as per the v1.Volume spec.
	// - podUID: The UID of the enclosing pod
	NewBlockVolumeUnmapper(name string, podUID types.UID) (BlockVolumeUnmapper, error)
	// ConstructBlockVolumeSpec constructs a volume spec based on the given
	// podUID, volume name and a pod device map path.
	// The spec may have incomplete information due to limited information
	// from input. This function is used by volume manager to reconstruct
	// volume spec by reading the volume directories from disk.
	ConstructBlockVolumeSpec(podUID types.UID, volumeName, volumePath string) (*Spec, error)
}

BlockVolumePlugin is an extend interface of VolumePlugin and is used for block volumes support.

type BlockVolumeUnmapper added in v1.9.0

type BlockVolumeUnmapper interface {
	BlockVolume
	// TearDownDevice removes traces of the SetUpDevice procedure under
	// a self-determined directory.
	// If the plugin is non-attachable, this method detaches the volume
	// from a node.
	TearDownDevice(mapPath string, devicePath string) error
}

BlockVolumeUnmapper interface provides methods to cleanup/unmap the volumes.

type BulkVolumeVerifier added in v1.6.0

type BulkVolumeVerifier interface {
	// BulkVerifyVolumes checks whether the list of volumes still attached to the
	// the clusters in the node. It returns a map which maps from the volume spec to the checking result.
	// If an error occurs during check - error should be returned and volume on nodes
	// should be assumed as still attached.
	BulkVerifyVolumes(volumesByNode map[types.NodeName][]*Spec) (map[types.NodeName]map[*Spec]bool, error)
}

type CSIVolumePhaseType added in v1.14.0

type CSIVolumePhaseType string

CSIVolumePhaseType stores information about CSI volume path.

type DeletableVolumePlugin added in v1.1.0

type DeletableVolumePlugin interface {
	VolumePlugin
	// NewDeleter creates a new volume.Deleter which knows how to delete this
	// resource in accordance with the underlying storage provider after the
	// volume's release from a claim
	NewDeleter(spec *Spec) (Deleter, error)
}

DeletableVolumePlugin is an extended interface of VolumePlugin and is used by persistent volumes that want to be deleted from the cluster after their release from a PersistentVolumeClaim.

type Deleter added in v1.1.0

type Deleter interface {
	Volume
	// This method should block until completion.
	// deletedVolumeInUseError returned from this function will not be reported
	// as error and it will be sent as "Info" event to the PV being deleted. The
	// volume controller will retry deleting the volume in the next periodic
	// sync. This can be used to postpone deletion of a volume that is being
	// detached from a node. Deletion of such volume would fail anyway and such
	// error would confuse users.
	Delete() error
}

Deleter removes the resource from the underlying storage provider. Calls to this method should block until the deletion is complete. Any error returned indicates the volume has failed to be reclaimed. A nil return indicates success.

type Detacher added in v1.2.0

type Detacher interface {
	DeviceUnmounter
	// Detach the given volume from the node with the given Name.
	// volumeName is name of the volume as returned from plugin's
	// GetVolumeName().
	Detach(volumeName string, nodeName types.NodeName) error
}

Detacher can detach a volume from a node.

type DeviceMountableVolumePlugin added in v1.12.0

type DeviceMountableVolumePlugin interface {
	VolumePlugin
	NewDeviceMounter() (DeviceMounter, error)
	NewDeviceUnmounter() (DeviceUnmounter, error)
	GetDeviceMountRefs(deviceMountPath string) ([]string, error)
}

DeviceMountableVolumePlugin is an extended interface of VolumePlugin and is used for volumes that requires mount device to a node before binding to volume to pod.

type DeviceMounter added in v1.12.0

type DeviceMounter interface {
	// GetDeviceMountPath returns a path where the device should
	// be mounted after it is attached. This is a global mount
	// point which should be bind mounted for individual volumes.
	GetDeviceMountPath(spec *Spec) (string, error)

	// MountDevice mounts the disk to a global path which
	// individual pods can then bind mount
	// Note that devicePath can be empty if the volume plugin does not implement any of Attach and WaitForAttach methods.
	MountDevice(spec *Spec, devicePath string, deviceMountPath string) error
}

DeviceMounter can mount a block volume to a global path.

type DeviceUnmounter added in v1.12.0

type DeviceUnmounter interface {
	// UnmountDevice unmounts the global mount of the disk. This
	// should only be called once all bind mounts have been
	// unmounted.
	UnmountDevice(deviceMountPath string) error
}

DeviceUnmounter can unmount a block volume from the global path.

type DynamicPluginProber added in v1.8.0

type DynamicPluginProber interface {
	Init() error

	// If an error occurs, events are undefined.
	Probe() (events []ProbeEvent, err error)
}

type ExpandableVolumePlugin added in v1.8.0

type ExpandableVolumePlugin interface {
	VolumePlugin
	ExpandVolumeDevice(spec *Spec, newSize resource.Quantity, oldSize resource.Quantity) (resource.Quantity, error)
	RequiresFSResize() bool
}

ExpandableVolumePlugin is an extended interface of VolumePlugin and is used for volumes that can be expanded via control-plane ExpandVolumeDevice call.

type KubeletVolumeHost added in v1.14.0

type KubeletVolumeHost interface {
	// SetKubeletError lets plugins set an error on the Kubelet runtime status
	// that will cause the Kubelet to post NotReady status with the error message provided
	SetKubeletError(err error)

	// GetInformerFactory returns the informer factory for CSIDriverLister
	GetInformerFactory() informers.SharedInformerFactory
	// CSIDriverLister returns the informer lister for the CSIDriver API Object
	CSIDriverLister() storagelisters.CSIDriverLister
	// CSIDriverSynced returns the informer synced for the CSIDriver API Object
	CSIDriversSynced() cache.InformerSynced
	// WaitForCacheSync is a helper function that waits for cache sync for CSIDriverLister
	WaitForCacheSync() error
}

KubeletVolumeHost is a Kubelet specific interface that plugins can use to access the kubelet.

type Metrics added in v1.2.0

type Metrics struct {
	// The time at which these stats were updated.
	Time metav1.Time

	// Used represents the total bytes used by the Volume.
	// Note: For block devices this maybe more than the total size of the files.
	Used *resource.Quantity

	// Capacity represents the total capacity (bytes) of the volume's
	// underlying storage. For Volumes that share a filesystem with the host
	// (e.g. emptydir, hostpath) this is the size of the underlying storage,
	// and will not equal Used + Available as the fs is shared.
	Capacity *resource.Quantity

	// Available represents the storage space available (bytes) for the
	// Volume. For Volumes that share a filesystem with the host (e.g.
	// emptydir, hostpath), this is the available space on the underlying
	// storage, and is shared with host processes and other Volumes.
	Available *resource.Quantity

	// InodesUsed represents the total inodes used by the Volume.
	InodesUsed *resource.Quantity

	// Inodes represents the total number of inodes available in the volume.
	// For volumes that share a filesystem with the host (e.g. emptydir, hostpath),
	// this is the inodes available in the underlying storage,
	// and will not equal InodesUsed + InodesFree as the fs is shared.
	Inodes *resource.Quantity

	// InodesFree represent the inodes available for the volume.  For Volumes that share
	// a filesystem with the host (e.g. emptydir, hostpath), this is the free inodes
	// on the underlying storage, and is shared with host processes and other volumes
	InodesFree *resource.Quantity
}

Metrics represents the used and available bytes of the Volume.

type MetricsError added in v1.5.0

type MetricsError struct {
	Code int
	Msg  string
}

MetricsError to distinguish different Metrics Errors.

func NewFsInfoFailedError added in v1.5.0

func NewFsInfoFailedError(err error) *MetricsError

NewFsInfoFailedError creates a new MetricsError with code FsInfoFailed.

func NewNoPathDefinedError added in v1.5.0

func NewNoPathDefinedError() *MetricsError

NewNoPathDefined creates a new MetricsError with code NoPathDefined.

func NewNotSupportedError added in v1.5.0

func NewNotSupportedError() *MetricsError

NewNotSupportedError creates a new MetricsError with code NotSupported.

func (*MetricsError) Error added in v1.5.0

func (e *MetricsError) Error() string

type MetricsNil added in v1.2.0

type MetricsNil struct{}

MetricsNil represents a MetricsProvider that does not support returning Metrics. It serves as a placeholder for Volumes that do not yet support metrics.

func (*MetricsNil) GetMetrics added in v1.2.0

func (*MetricsNil) GetMetrics() (*Metrics, error)

GetMetrics returns an empty Metrics and an error. See MetricsProvider.GetMetrics

type MetricsProvider added in v1.2.0

type MetricsProvider interface {
	// GetMetrics returns the Metrics for the Volume. Maybe expensive for
	// some implementations.
	GetMetrics() (*Metrics, error)
}

MetricsProvider exposes metrics (e.g. used,available space) related to a Volume.

func NewCachedMetrics added in v1.2.0

func NewCachedMetrics(provider MetricsProvider) MetricsProvider

NewCachedMetrics creates a new cachedMetrics wrapping another MetricsProvider and caching the results.

func NewMetricsDu added in v1.2.0

func NewMetricsDu(path string) MetricsProvider

NewMetricsDu creates a new metricsDu with the Volume path.

func NewMetricsStatFS added in v1.3.0

func NewMetricsStatFS(path string) MetricsProvider

NewMetricsStatfs creates a new metricsStatFS with the Volume path.

type Mounter added in v1.3.0

type Mounter interface {
	// Uses Interface to provide the path for Docker binds.
	Volume

	// CanMount is called immediately prior to Setup to check if
	// the required components (binaries, etc.) are available on
	// the underlying node to complete the subsequent SetUp (mount)
	// operation. If CanMount returns error, the mount operation is
	// aborted and an event is generated indicating that the node
	// does not have the required binaries to complete the mount.
	// If CanMount succeeds, the mount operation continues
	// normally. The CanMount check can be enabled or disabled
	// using the experimental-check-mount-binaries binary flag
	CanMount() error

	// SetUp prepares and mounts/unpacks the volume to a
	// self-determined directory path. The mount point and its
	// content should be owned by 'fsGroup' so that it can be
	// accessed by the pod. This may be called more than once, so
	// implementations must be idempotent.
	SetUp(fsGroup *int64) error
	// SetUpAt prepares and mounts/unpacks the volume to the
	// specified directory path, which may or may not exist yet.
	// The mount point and its content should be owned by
	// 'fsGroup' so that it can be accessed by the pod. This may
	// be called more than once, so implementations must be
	// idempotent.
	SetUpAt(dir string, fsGroup *int64) error
	// GetAttributes returns the attributes of the mounter.
	// This function is called after SetUp()/SetUpAt().
	GetAttributes() Attributes
}

Mounter interface provides methods to set up/mount the volume.

type NodeExpandableVolumePlugin added in v1.14.0

type NodeExpandableVolumePlugin interface {
	VolumePlugin
	RequiresFSResize() bool
	// NodeExpand expands volume on given deviceMountPath and returns true if resize is successful.
	NodeExpand(resizeOptions NodeResizeOptions) (bool, error)
}

NodeExpandableVolumePlugin is an expanded interface of VolumePlugin and is used for volumes that require expansion on the node via NodeExpand call.

type NodeResizeOptions added in v1.14.0

type NodeResizeOptions struct {
	VolumeSpec *Spec

	// DevicePath - location of actual device on the node. In case of CSI
	// this just could be volumeID
	DevicePath string

	// DeviceMountPath location where device is mounted on the node. If volume type
	// is attachable - this would be global mount path otherwise
	// it would be location where volume was mounted for the pod
	DeviceMountPath string

	NewSize resource.Quantity
	OldSize resource.Quantity

	// CSIVolumePhase contains volume phase on the node
	CSIVolumePhase CSIVolumePhaseType
}

NodeResizeOptions contain options to be passed for node expansion.

type PersistentVolumePlugin added in v0.14.0

type PersistentVolumePlugin interface {
	VolumePlugin
	// GetAccessModes describes the ways a given volume can be accessed/mounted.
	GetAccessModes() []v1.PersistentVolumeAccessMode
}

PersistentVolumePlugin is an extended interface of VolumePlugin and is used by volumes that want to provide long term persistence of data

type ProbeEvent added in v1.11.0

type ProbeEvent struct {
	Plugin     VolumePlugin // VolumePlugin that was added/updated/removed. if ProbeEvent.Op is 'ProbeRemove', Plugin should be nil
	PluginName string
	Op         ProbeOperation // The operation to the plugin
}

type ProbeOperation added in v1.11.0

type ProbeOperation uint32

type ProvisionableVolumePlugin added in v1.2.0

type ProvisionableVolumePlugin interface {
	VolumePlugin
	// NewProvisioner creates a new volume.Provisioner which knows how to
	// create PersistentVolumes in accordance with the plugin's underlying
	// storage provider
	NewProvisioner(options VolumeOptions) (Provisioner, error)
}

ProvisionableVolumePlugin is an extended interface of VolumePlugin and is used to create volumes for the cluster.

type Provisioner added in v1.2.0

type Provisioner interface {
	// Provision creates the resource by allocating the underlying volume in a
	// storage system. This method should block until completion and returns
	// PersistentVolume representing the created storage resource.
	Provision(selectedNode *v1.Node, allowedTopologies []v1.TopologySelectorTerm) (*v1.PersistentVolume, error)
}

Provisioner is an interface that creates templates for PersistentVolumes and can create the volume as a new resource in the infrastructure provider.

type RecyclableVolumePlugin added in v0.19.0

type RecyclableVolumePlugin interface {
	VolumePlugin

	// Recycle knows how to reclaim this
	// resource after the volume's release from a PersistentVolumeClaim.
	// Recycle will use the provided recorder to write any events that might be
	// interesting to user. It's expected that caller will pass these events to
	// the PV being recycled.
	Recycle(pvName string, spec *Spec, eventRecorder recyclerclient.RecycleEventRecorder) error
}

RecyclableVolumePlugin is an extended interface of VolumePlugin and is used by persistent volumes that want to be recycled before being made available again to new claims

type Spec added in v0.16.1

type Spec struct {
	Volume           *v1.Volume
	PersistentVolume *v1.PersistentVolume
	ReadOnly         bool
}

Spec is an internal representation of a volume. All API volume types translate to Spec.

func NewSpecFromPersistentVolume added in v0.16.1

func NewSpecFromPersistentVolume(pv *v1.PersistentVolume, readOnly bool) *Spec

NewSpecFromPersistentVolume creates an Spec from an v1.PersistentVolume

func NewSpecFromVolume added in v0.16.1

func NewSpecFromVolume(vs *v1.Volume) *Spec

NewSpecFromVolume creates an Spec from an v1.Volume

func (*Spec) IsKubeletExpandable added in v1.13.0

func (spec *Spec) IsKubeletExpandable() bool

IsKubeletExpandable returns true for volume types that can be expanded only by the node and not the controller. Currently Flex volume is the only one in this category since it is typically not installed on the controller

func (*Spec) KubeletExpandablePluginName added in v1.13.0

func (spec *Spec) KubeletExpandablePluginName() string

KubeletExpandablePluginName creates and returns a name for the plugin this is used in context on the controller where the plugin lookup fails as volume expansion on controller isn't supported, but a plugin name is required

func (*Spec) Name added in v0.16.1

func (spec *Spec) Name() string

Name returns the name of either Volume or PersistentVolume, one of which must not be nil.

type Unmounter added in v1.3.0

type Unmounter interface {
	Volume
	// TearDown unmounts the volume from a self-determined directory and
	// removes traces of the SetUp procedure.
	TearDown() error
	// TearDown unmounts the volume from the specified directory and
	// removes traces of the SetUp procedure.
	TearDownAt(dir string) error
}

Unmounter interface provides methods to cleanup/unmount the volumes.

type Volume added in v0.14.0

type Volume interface {
	// GetPath returns the path to which the volume should be mounted for the
	// pod.
	GetPath() string

	// MetricsProvider embeds methods for exposing metrics (e.g.
	// used, available space).
	MetricsProvider
}

Volume represents a directory used by pods or hosts on a node. All method implementations of methods in the volume interface must be idempotent.

type VolumeConfig added in v1.1.0

type VolumeConfig struct {
	// RecyclerPodTemplate is pod template that understands how to scrub clean
	// a persistent volume after its release. The template is used by plugins
	// which override specific properties of the pod in accordance with that
	// plugin. See NewPersistentVolumeRecyclerPodTemplate for the properties
	// that are expected to be overridden.
	RecyclerPodTemplate *v1.Pod

	// RecyclerMinimumTimeout is the minimum amount of time in seconds for the
	// recycler pod's ActiveDeadlineSeconds attribute. Added to the minimum
	// timeout is the increment per Gi of capacity.
	RecyclerMinimumTimeout int

	// RecyclerTimeoutIncrement is the number of seconds added to the recycler
	// pod's ActiveDeadlineSeconds for each Gi of capacity in the persistent
	// volume. Example: 5Gi volume x 30s increment = 150s + 30s minimum = 180s
	// ActiveDeadlineSeconds for recycler pod
	RecyclerTimeoutIncrement int

	// PVName is name of the PersistentVolume instance that is being recycled.
	// It is used to generate unique recycler pod name.
	PVName string

	// OtherAttributes stores config as strings.  These strings are opaque to
	// the system and only understood by the binary hosting the plugin and the
	// plugin itself.
	OtherAttributes map[string]string

	// ProvisioningEnabled configures whether provisioning of this plugin is
	// enabled or not. Currently used only in host_path plugin.
	ProvisioningEnabled bool
}

VolumeConfig is how volume plugins receive configuration. An instance specific to the plugin will be passed to the plugin's ProbeVolumePlugins(config) func. Reasonable defaults will be provided by the binary hosting the plugins while allowing override of those default values. Those config values are then set to an instance of VolumeConfig and passed to the plugin.

Values in VolumeConfig are intended to be relevant to several plugins, but not necessarily all plugins. The preference is to leverage strong typing in this struct. All config items must have a descriptive but non-specific name (i.e, RecyclerMinimumTimeout is OK but RecyclerMinimumTimeoutForNFS is !OK). An instance of config will be given directly to the plugin, so config names specific to plugins are unneeded and wrongly expose plugins in this VolumeConfig struct.

OtherAttributes is a map of string values intended for one-off configuration of a plugin or config that is only relevant to a single plugin. All values are passed by string and require interpretation by the plugin. Passing config as strings is the least desirable option but can be used for truly one-off configuration. The binary should still use strong typing for this value when binding CLI values before they are passed as strings in OtherAttributes.

type VolumeHost added in v0.14.0

type VolumeHost interface {
	// GetPluginDir returns the absolute path to a directory under which
	// a given plugin may store data.  This directory might not actually
	// exist on disk yet.  For plugin data that is per-pod, see
	// GetPodPluginDir().
	GetPluginDir(pluginName string) string

	// GetVolumeDevicePluginDir returns the absolute path to a directory
	// under which a given plugin may store data.
	// ex. plugins/kubernetes.io/{PluginName}/{DefaultKubeletVolumeDevicesDirName}/{volumePluginDependentPath}/
	GetVolumeDevicePluginDir(pluginName string) string

	// GetPodsDir returns the absolute path to a directory where all the pods
	// information is stored
	GetPodsDir() string

	// GetPodVolumeDir returns the absolute path a directory which
	// represents the named volume under the named plugin for the given
	// pod.  If the specified pod does not exist, the result of this call
	// might not exist.
	GetPodVolumeDir(podUID types.UID, pluginName string, volumeName string) string

	// GetPodPluginDir returns the absolute path to a directory under which
	// a given plugin may store data for a given pod.  If the specified pod
	// does not exist, the result of this call might not exist.  This
	// directory might not actually exist on disk yet.
	GetPodPluginDir(podUID types.UID, pluginName string) string

	// GetPodVolumeDeviceDir returns the absolute path a directory which
	// represents the named plugin for the given pod.
	// If the specified pod does not exist, the result of this call
	// might not exist.
	// ex. pods/{podUid}/{DefaultKubeletVolumeDevicesDirName}/{escapeQualifiedPluginName}/
	GetPodVolumeDeviceDir(podUID types.UID, pluginName string) string

	// GetKubeClient returns a client interface
	GetKubeClient() clientset.Interface

	// NewWrapperMounter finds an appropriate plugin with which to handle
	// the provided spec.  This is used to implement volume plugins which
	// "wrap" other plugins.  For example, the "secret" volume is
	// implemented in terms of the "emptyDir" volume.
	NewWrapperMounter(volName string, spec Spec, pod *v1.Pod, opts VolumeOptions) (Mounter, error)

	// NewWrapperUnmounter finds an appropriate plugin with which to handle
	// the provided spec.  See comments on NewWrapperMounter for more
	// context.
	NewWrapperUnmounter(volName string, spec Spec, podUID types.UID) (Unmounter, error)

	// Get cloud provider from kubelet.
	GetCloudProvider() cloudprovider.Interface

	// Get mounter interface.
	GetMounter(pluginName string) mount.Interface

	// Returns the hostname of the host kubelet is running on
	GetHostName() string

	// Returns host IP or nil in the case of error.
	GetHostIP() (net.IP, error)

	// Returns node allocatable.
	GetNodeAllocatable() (v1.ResourceList, error)

	// Returns a function that returns a secret.
	GetSecretFunc() func(namespace, name string) (*v1.Secret, error)

	// Returns a function that returns a configmap.
	GetConfigMapFunc() func(namespace, name string) (*v1.ConfigMap, error)

	GetServiceAccountTokenFunc() func(namespace, name string, tr *authenticationv1.TokenRequest) (*authenticationv1.TokenRequest, error)

	DeleteServiceAccountTokenFunc() func(podUID types.UID)

	// Returns an interface that should be used to execute any utilities in volume plugins
	GetExec(pluginName string) mount.Exec

	// Returns the labels on the node
	GetNodeLabels() (map[string]string, error)

	// Returns the name of the node
	GetNodeName() types.NodeName

	// Returns the event recorder of kubelet.
	GetEventRecorder() record.EventRecorder

	// Returns an interface that should be used to execute subpath operations
	GetSubpather() subpath.Interface
}

VolumeHost is an interface that plugins can use to access the kubelet.

type VolumeOptions added in v0.15.0

type VolumeOptions struct {

	// Reclamation policy for a persistent volume
	PersistentVolumeReclaimPolicy v1.PersistentVolumeReclaimPolicy
	// Mount options for a persistent volume
	MountOptions []string
	// Suggested PV.Name of the PersistentVolume to provision.
	// This is a generated name guaranteed to be unique in Kubernetes cluster.
	// If you choose not to use it as volume name, ensure uniqueness by either
	// combining it with your value or create unique values of your own.
	PVName string
	// PVC is reference to the claim that lead to provisioning of a new PV.
	// Provisioners *must* create a PV that would be matched by this PVC,
	// i.e. with required capacity, accessMode, labels matching PVC.Selector and
	// so on.
	PVC *v1.PersistentVolumeClaim
	// Unique name of Kubernetes cluster.
	ClusterName string
	// Tags to attach to the real volume in the cloud provider - e.g. AWS EBS
	CloudTags *map[string]string
	// Volume provisioning parameters from StorageClass
	Parameters map[string]string
}

VolumeOptions contains option information about a volume.

type VolumePlugin added in v0.14.0

type VolumePlugin interface {
	// Init initializes the plugin.  This will be called exactly once
	// before any New* calls are made - implementations of plugins may
	// depend on this.
	Init(host VolumeHost) error

	// Name returns the plugin's name.  Plugins must use namespaced names
	// such as "example.com/volume" and contain exactly one '/' character.
	// The "kubernetes.io" namespace is reserved for plugins which are
	// bundled with kubernetes.
	GetPluginName() string

	// GetVolumeName returns the name/ID to uniquely identifying the actual
	// backing device, directory, path, etc. referenced by the specified volume
	// spec.
	// For Attachable volumes, this value must be able to be passed back to
	// volume Detach methods to identify the device to act on.
	// If the plugin does not support the given spec, this returns an error.
	GetVolumeName(spec *Spec) (string, error)

	// CanSupport tests whether the plugin supports a given volume
	// specification from the API.  The spec pointer should be considered
	// const.
	CanSupport(spec *Spec) bool

	// IsMigratedToCSI tests whether a CSIDriver implements this plugin's
	// functionality
	IsMigratedToCSI() bool

	// RequiresRemount returns true if this plugin requires mount calls to be
	// reexecuted. Atomically updating volumes, like Downward API, depend on
	// this to update the contents of the volume.
	RequiresRemount() bool

	// NewMounter creates a new volume.Mounter from an API specification.
	// Ownership of the spec pointer in *not* transferred.
	// - spec: The v1.Volume spec
	// - pod: The enclosing pod
	NewMounter(spec *Spec, podRef *v1.Pod, opts VolumeOptions) (Mounter, error)

	// NewUnmounter creates a new volume.Unmounter from recoverable state.
	// - name: The volume name, as per the v1.Volume spec.
	// - podUID: The UID of the enclosing pod
	NewUnmounter(name string, podUID types.UID) (Unmounter, error)

	// ConstructVolumeSpec constructs a volume spec based on the given volume name
	// and volumePath. The spec may have incomplete information due to limited
	// information from input. This function is used by volume manager to reconstruct
	// volume spec by reading the volume directories from disk
	ConstructVolumeSpec(volumeName, volumePath string) (*Spec, error)

	// SupportsMountOption returns true if volume plugins supports Mount options
	// Specifying mount options in a volume plugin that doesn't support
	// user specified mount options will result in error creating persistent volumes
	SupportsMountOption() bool

	// SupportsBulkVolumeVerification checks if volume plugin type is capable
	// of enabling bulk polling of all nodes. This can speed up verification of
	// attached volumes by quite a bit, but underlying pluging must support it.
	SupportsBulkVolumeVerification() bool
}

VolumePlugin is an interface to volume plugins that can be used on a kubernetes node (e.g. by kubelet) to instantiate and manage volumes.

type VolumePluginMgr added in v0.14.0

type VolumePluginMgr struct {
	Host VolumeHost
	// contains filtered or unexported fields
}

VolumePluginMgr tracks registered plugins.

func (*VolumePluginMgr) FindAttachablePluginByName added in v1.2.0

func (pm *VolumePluginMgr) FindAttachablePluginByName(name string) (AttachableVolumePlugin, error)

FindAttachablePluginByName fetches an attachable volume plugin by name. Unlike the other "FindPlugin" methods, this does not return error if no plugin is found. All volumes require a mounter and unmounter, but not every volume will have an attacher/detacher.

func (*VolumePluginMgr) FindAttachablePluginBySpec added in v1.2.0

func (pm *VolumePluginMgr) FindAttachablePluginBySpec(spec *Spec) (AttachableVolumePlugin, error)

FindAttachablePluginBySpec fetches a persistent volume plugin by spec. Unlike the other "FindPlugin" methods, this does not return error if no plugin is found. All volumes require a mounter and unmounter, but not every volume will have an attacher/detacher.

func (*VolumePluginMgr) FindCreatablePluginBySpec added in v1.1.0

func (pm *VolumePluginMgr) FindCreatablePluginBySpec(spec *Spec) (ProvisionableVolumePlugin, error)

FindCreatablePluginBySpec fetches a persistent volume plugin by name. If no plugin is found, returns error.

func (*VolumePluginMgr) FindDeletablePluginByName added in v1.4.1

func (pm *VolumePluginMgr) FindDeletablePluginByName(name string) (DeletableVolumePlugin, error)

FindDeletablePluginByName fetches a persistent volume plugin by name. If no plugin is found, returns error.

func (*VolumePluginMgr) FindDeletablePluginBySpec added in v1.1.0

func (pm *VolumePluginMgr) FindDeletablePluginBySpec(spec *Spec) (DeletableVolumePlugin, error)

FindDeletablePluginBySppec fetches a persistent volume plugin by spec. If no plugin is found, returns error.

func (*VolumePluginMgr) FindDeviceMountablePluginByName added in v1.12.0

func (pm *VolumePluginMgr) FindDeviceMountablePluginByName(name string) (DeviceMountableVolumePlugin, error)

FindDeviceMountablePluginByName fetches a devicemountable volume plugin by name.

func (*VolumePluginMgr) FindDeviceMountablePluginBySpec added in v1.12.0

func (pm *VolumePluginMgr) FindDeviceMountablePluginBySpec(spec *Spec) (DeviceMountableVolumePlugin, error)

FindDeviceMountablePluginBySpec fetches a persistent volume plugin by spec.

func (*VolumePluginMgr) FindExpandablePluginByName added in v1.8.0

func (pm *VolumePluginMgr) FindExpandablePluginByName(name string) (ExpandableVolumePlugin, error)

FindExpandablePluginBySpec fetches a persistent volume plugin by name.

func (*VolumePluginMgr) FindExpandablePluginBySpec added in v1.8.0

func (pm *VolumePluginMgr) FindExpandablePluginBySpec(spec *Spec) (ExpandableVolumePlugin, error)

FindExpandablePluginBySpec fetches a persistent volume plugin by spec.

func (*VolumePluginMgr) FindMapperPluginByName added in v1.9.0

func (pm *VolumePluginMgr) FindMapperPluginByName(name string) (BlockVolumePlugin, error)

FindMapperPluginByName fetches a block volume plugin by name.

func (*VolumePluginMgr) FindMapperPluginBySpec added in v1.9.0

func (pm *VolumePluginMgr) FindMapperPluginBySpec(spec *Spec) (BlockVolumePlugin, error)

FindMapperPluginBySpec fetches a block volume plugin by spec.

func (*VolumePluginMgr) FindNodeExpandablePluginByName added in v1.14.0

func (pm *VolumePluginMgr) FindNodeExpandablePluginByName(name string) (NodeExpandableVolumePlugin, error)

FindNodeExpandablePluginByName fetches a persistent volume plugin by name

func (*VolumePluginMgr) FindNodeExpandablePluginBySpec added in v1.14.0

func (pm *VolumePluginMgr) FindNodeExpandablePluginBySpec(spec *Spec) (NodeExpandableVolumePlugin, error)

FindNodeExpandablePluginBySpec fetches a persistent volume plugin by spec

func (*VolumePluginMgr) FindPersistentPluginByName added in v0.14.0

func (pm *VolumePluginMgr) FindPersistentPluginByName(name string) (PersistentVolumePlugin, error)

FindPersistentPluginByName fetches a persistent volume plugin by name. If no plugin is found, returns error.

func (*VolumePluginMgr) FindPersistentPluginBySpec added in v0.19.0

func (pm *VolumePluginMgr) FindPersistentPluginBySpec(spec *Spec) (PersistentVolumePlugin, error)

FindPersistentPluginBySpec looks for a persistent volume plugin that can support a given volume specification. If no plugin is found, return an error

func (*VolumePluginMgr) FindPluginByName added in v0.14.0

func (pm *VolumePluginMgr) FindPluginByName(name string) (VolumePlugin, error)

FindPluginByName fetches a plugin by name or by legacy name. If no plugin is found, returns error.

func (*VolumePluginMgr) FindPluginBySpec added in v0.14.0

func (pm *VolumePluginMgr) FindPluginBySpec(spec *Spec) (VolumePlugin, error)

FindPluginBySpec looks for a plugin that can support a given volume specification. If no plugins can support or more than one plugin can support it, return error.

func (*VolumePluginMgr) FindProvisionablePluginByName added in v1.4.1

func (pm *VolumePluginMgr) FindProvisionablePluginByName(name string) (ProvisionableVolumePlugin, error)

FindProvisionablePluginByName fetches a persistent volume plugin by name. If no plugin is found, returns error.

func (*VolumePluginMgr) FindRecyclablePluginBySpec added in v0.19.0

func (pm *VolumePluginMgr) FindRecyclablePluginBySpec(spec *Spec) (RecyclableVolumePlugin, error)

FindRecyclablePluginByName fetches a persistent volume plugin by name. If no plugin is found, returns error.

func (*VolumePluginMgr) FindVolumePluginWithLimitsBySpec added in v1.11.0

func (pm *VolumePluginMgr) FindVolumePluginWithLimitsBySpec(spec *Spec) (VolumePluginWithAttachLimits, error)

FindVolumePluginWithLimitsBySpec returns volume plugin that has a limit on how many of them can be attached to a node

func (*VolumePluginMgr) InitPlugins added in v0.14.0

func (pm *VolumePluginMgr) InitPlugins(plugins []VolumePlugin, prober DynamicPluginProber, host VolumeHost) error

InitPlugins initializes each plugin. All plugins must have unique names. This must be called exactly once before any New* methods are called on any plugins.

func (*VolumePluginMgr) IsPluginMigratableBySpec added in v1.14.0

func (pm *VolumePluginMgr) IsPluginMigratableBySpec(spec *Spec) (bool, error)

IsPluginMigratableBySpec looks for a plugin that can support a given volume specification and whether that plugin is Migratable. If no plugins can support or more than one plugin can support it, return error.

func (*VolumePluginMgr) ListVolumePluginWithLimits added in v1.11.0

func (pm *VolumePluginMgr) ListVolumePluginWithLimits() []VolumePluginWithAttachLimits

ListVolumePluginWithLimits returns plugins that have volume limits on nodes

func (*VolumePluginMgr) Run added in v1.14.4

func (pm *VolumePluginMgr) Run(stopCh <-chan struct{})

type VolumePluginWithAttachLimits added in v1.11.0

type VolumePluginWithAttachLimits interface {
	VolumePlugin
	// Return maximum number of volumes that can be attached to a node for this plugin.
	// The key must be same as string returned by VolumeLimitKey function. The returned
	// map may look like:
	//     - { "storage-limits-aws-ebs": 39 }
	//     - { "storage-limits-gce-pd": 10 }
	// A volume plugin may return error from this function - if it can not be used on a given node or not
	// applicable in given environment (where environment could be cloudprovider or any other dependency)
	// For example - calling this function for EBS volume plugin on a GCE node should
	// result in error.
	// The returned values are stored in node allocatable property and will be used
	// by scheduler to determine how many pods with volumes can be scheduled on given node.
	GetVolumeLimits() (map[string]int64, error)
	// Return volume limit key string to be used in node capacity constraints
	// The key must start with prefix storage-limits-. For example:
	//    - storage-limits-aws-ebs
	//    - storage-limits-csi-cinder
	// The key should respect character limit of ResourceName type
	// This function may be called by kubelet or scheduler to identify node allocatable property
	// which stores volumes limits.
	VolumeLimitKey(spec *Spec) string
}

VolumePluginWithAttachLimits is an extended interface of VolumePlugin that restricts number of volumes that can be attached to a node.

Directories

Path Synopsis
Package awsebs contains the internal representation of AWS Elastic Block Store volumes.
Package awsebs contains the internal representation of AWS Elastic Block Store volumes.
Package azure_file contains the internal representation of Azure File Service Volume
Package azure_file contains the internal representation of Azure File Service Volume
Package cephfs contains the internal representation of Ceph file system (CephFS) volumes.
Package cephfs contains the internal representation of Ceph file system (CephFS) volumes.
Package cinder contains the internal representation of cinder volumes.
Package cinder contains the internal representation of cinder volumes.
Package configmap contains the internal representation of configMap volumes.
Package configmap contains the internal representation of configMap volumes.
csi
nodeinfomanager
Package nodeinfomanager includes internal functions used to add/delete labels to kubernetes nodes for corresponding CSI drivers
Package nodeinfomanager includes internal functions used to add/delete labels to kubernetes nodes for corresponding CSI drivers
Package emptydir contains the internal representation of emptyDir volumes.
Package emptydir contains the internal representation of emptyDir volumes.
Package fc contains the internal representation of Fibre Channel (fc) volumes.
Package fc contains the internal representation of Fibre Channel (fc) volumes.
Package flocker contains the internal representation of Flocker volumes
Package flocker contains the internal representation of Flocker volumes
Package gcepd contains the internal representation of GCE PersistentDisk volumes.
Package gcepd contains the internal representation of GCE PersistentDisk volumes.
Package git_repo contains the internal representation of git repo volumes.
Package git_repo contains the internal representation of git repo volumes.
Package glusterfs contains the internal representation of glusterfs volumes.
Package glusterfs contains the internal representation of glusterfs volumes.
Package host_path contains the internal representation of hostPath volumes.
Package host_path contains the internal representation of hostPath volumes.
Package iscsi contains the internal representation of Internet Small Computer System Interface (iSCSI) volumes.
Package iscsi contains the internal representation of Internet Small Computer System Interface (iSCSI) volumes.
Package local contains the internal representation of local volumes
Package local contains the internal representation of local volumes
Package nfs contains the internal representation of network file system (NFS) volumes.
Package nfs contains the internal representation of network file system (NFS) volumes.
Package portworx contains the internal representation of Portworx Block Device volumes.
Package portworx contains the internal representation of Portworx Block Device volumes.
Package quobyte contains the internal representation of Quobyte volumes.
Package quobyte contains the internal representation of Quobyte volumes.
Package rbd contains the internal representation of Rados Block Store (Ceph) volumes.
Package rbd contains the internal representation of Rados Block Store (Ceph) volumes.
Package secret contains the internal representation of secret volumes.
Package secret contains the internal representation of secret volumes.
Package storageos contains the internal representation of StorageOS PersistentDisk volumes.
Package storageos contains the internal representation of StorageOS PersistentDisk volumes.
Package util contains utility code for use by volume plugins.
Package util contains utility code for use by volume plugins.
fs
nestedpendingoperations
Package nestedpendingoperations is a modified implementation of pkg/util/goroutinemap.
Package nestedpendingoperations is a modified implementation of pkg/util/goroutinemap.
operationexecutor
Package operationexecutor implements interfaces that enable execution of attach, detach, mount, and unmount operations with a nestedpendingoperations so that more than one operation is never triggered on the same volume for the same pod.
Package operationexecutor implements interfaces that enable execution of attach, detach, mount, and unmount operations with a nestedpendingoperations so that more than one operation is never triggered on the same volume for the same pod.
types
Package types defines types used only by volume components
Package types defines types used only by volume components

Jump to

Keyboard shortcuts

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