storage

package
v0.0.0-...-004e4dd Latest Latest
Warning

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

Go to latest
Published: Apr 23, 2024 License: AGPL-3.0 Imports: 22 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FilesystemInfo

func FilesystemInfo(ctx context.Context, client kubernetes.Interface,
	namespace string, volume corev1.Volume, volumeMount corev1.VolumeMount,
	now time.Time) (*caas.FilesystemInfo, error)

FilesystemInfo returns filesystem info.

func FilesystemStatus

func FilesystemStatus(pvcPhase corev1.PersistentVolumeClaimPhase) status.Status

FilesystemStatus returns filesystem status.

func GetMountPathForFilesystem

func GetMountPathForFilesystem(idx int, appName string, fs storage.KubernetesFilesystemParams) string

GetMountPathForFilesystem returns mount path.

func ParseStorageMode

func ParseStorageMode(attrs map[string]interface{}) (*corev1.PersistentVolumeAccessMode, error)

ParseStorageMode returns k8s persistent volume access mode.

func PersistentVolumeClaimSpec

func PersistentVolumeClaimSpec(params VolumeParams) *corev1.PersistentVolumeClaimSpec

PersistentVolumeClaimSpec returns k8s PVC spec.

func PushUniqueVolume

func PushUniqueVolume(podSpec *corev1.PodSpec, vol corev1.Volume, force bool) error

PushUniqueVolume ensures to only add unique volumes because k8s will not schedule pods if it has duplicated volumes. The existing volume will be replaced if force sets to true.

func PushUniqueVolumeClaimTemplate

func PushUniqueVolumeClaimTemplate(spec *apps.StatefulSetSpec, pvc corev1.PersistentVolumeClaim) error

PushUniqueVolumeClaimTemplate ensures to only add unique volume claim template to a statefulset.

func PushUniqueVolumeMount

func PushUniqueVolumeMount(container *corev1.Container, volMount corev1.VolumeMount)

PushUniqueVolumeMount ensures to only add unique volume mount to a container.

func StorageClassSpec

func StorageClassSpec(cfg k8s.StorageProvisioner, legacyLabels bool) *storagev1.StorageClass

StorageClassSpec converts storage provisioner config to k8s storage class.

func StorageProvisioner

func StorageProvisioner(namespace, model string, params VolumeParams) k8s.StorageProvisioner

StorageProvisioner returns storage provisioner.

func VolumeInfo

func VolumeInfo(pv *resources.PersistentVolume, now time.Time) caas.VolumeInfo

VolumeInfo returns volume info.

func VolumeSourceForFilesystem

func VolumeSourceForFilesystem(fs storage.KubernetesFilesystemParams) (*corev1.VolumeSource, error)

VolumeSourceForFilesystem return k8s volume source.

func VolumeStatus

func VolumeStatus(pvPhase corev1.PersistentVolumePhase) status.Status

VolumeStatus returns volume status.

Types

type PreferredStorage

type PreferredStorage interface {
	// Name returns the name used to uniquely identify this preferred storage
	// matcher.
	Name() string

	// Matches returns true if this matcher matches the supplied storage class.
	Matches(*storagev1.StorageClass) bool
}

PreferredStorage defines a matcher that can inject it's own logic into the preferred storage choice for a given storage class and decide if it's a match to it's rules.

type PreferredStorageAny

type PreferredStorageAny struct{}

PreferredStorageAny is an implementation of PreferredStorage that matches any storage class which isn't nil

func (*PreferredStorageAny) Matches

Matches implements PreferredStorage Matches.

func (*PreferredStorageAny) Name

func (_ *PreferredStorageAny) Name() string

Name implements PreferredStorage Name.

type PreferredStorageDefault

type PreferredStorageDefault struct{}

PreferredStorageDefault is an implementation of PreferredStorage that returns true if the supplied Kubernetes storage class is considered the default storage class for the cluster.

func (*PreferredStorageDefault) Matches

Matches implements PreferredStorage Matches.

func (*PreferredStorageDefault) Name

func (p *PreferredStorageDefault) Name() string

Name implements PreferredStorage Name.

type PreferredStorageList

type PreferredStorageList []PreferredStorage

PreferredStorageList defined an ordered list of PreferredStorage matches to test a given storage class against. The position of PreferredStorage matches matches indicating they're preference.

func PreferredOperatorStorageForCloud

func PreferredOperatorStorageForCloud(cloud string) PreferredStorageList

PreferredStorageForCloud returns a PreferredStorageList for the supplied cloud. If no cloud is found matching then a default list is provided.

func PreferredWorkloadStorageForCloud

func PreferredWorkloadStorageForCloud(cloud string) PreferredStorageList

PreferredWorkloadStorageForCloud returns a PreferredStorageList for the supplied cloud. If no cloud is found matching then a default list is provided.

func (PreferredStorageList) Matches

Matches is responsible for taking a Kubernetes StorageClass and testing it against each PreferredStorage matcher in this slice. The first match this function returns the preference of this storage class. Lower prefferences are better. If no match is return -1 and false is returned.

func (PreferredStorageList) Prepend

Prepend adds the supplied PreferredStorage matcher to the beginning of this list. This makes the PreferredStorage the highest storage matcher and the most preferred. Useful for when a user has nominated their own storage.

type PreferredStorageNominated

type PreferredStorageNominated struct {
	// StorageClassName is the name to match to for a Kubernetes storage class.
	StorageClassName string
}

PreferredStorageNominated is an implementation of PreferredStorage that matches based on a nominated storage class name.

func (*PreferredStorageNominated) Matches

Matches implements PreferredStorage Matches.

func (*PreferredStorageNominated) Name

Name implements PreferredStorage Name.

type PreferredStorageOperatorAnnotation

type PreferredStorageOperatorAnnotation struct{}

PreferredStorageOperatorAnnotation is an implementation of PreferredStorage that matches based on the operator storage annotation.

func (*PreferredStorageOperatorAnnotation) Matches

Matches implements PreferredStorage Matches.

func (*PreferredStorageOperatorAnnotation) Name

Name implements PreferredStorage Name.

type PreferredStorageProvisioner

type PreferredStorageProvisioner struct {
	// NameVal defines the value return by this struct's Name() method
	NameVal string

	// Provisioner is the string to match on the storage classess provisioner
	// member.
	Provisioner string
}

PreferredStorageProvisioner is an implementation of PreferredStorage that returns true if the supplied Kubernetes storage classes provisioner matches this provisioner.

func (*PreferredStorageProvisioner) Matches

Matches implements PreferredStorage Matches.

func (*PreferredStorageProvisioner) Name

Name implements PreferredStorage Name.

type PreferredStorageWorkloadAnnotation

type PreferredStorageWorkloadAnnotation struct{}

PreferredStorageOperatorAnnotation is an implementation of PreferredStorage that matches based on the workload storage annotation.

func (*PreferredStorageWorkloadAnnotation) Matches

Matches implements PreferredStorage Matches.

func (*PreferredStorageWorkloadAnnotation) Name

Name implements PreferredStorage Name.

type StorageConfig

type StorageConfig struct {
	// StorageClass defines a storage class
	// which will be created with the specified
	// provisioner and parameters if it doesn't
	// exist.
	StorageClass string

	// StorageProvisioner is the provisioner class to use.
	StorageProvisioner string

	// Parameters define attributes of the storage class.
	Parameters map[string]string

	// ReclaimPolicy defines the volume reclaim policy.
	ReclaimPolicy corev1.PersistentVolumeReclaimPolicy
}

StorageConfig defines config for storage.

func ParseStorageConfig

func ParseStorageConfig(attrs map[string]interface{}) (*StorageConfig, error)

ParseStorageConfig returns storage config.

type VolumeParams

type VolumeParams struct {
	Name          string
	StorageConfig *StorageConfig
	Size          resource.Quantity
	AccessMode    corev1.PersistentVolumeAccessMode
}

VolumeParams holds PV and PVC related config.

func ParseVolumeParams

func ParseVolumeParams(name string, size resource.Quantity, storageAttr map[string]interface{}) (*VolumeParams, error)

ParseVolumeParams returns a volume param.

Jump to

Keyboard shortcuts

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