persistentvolume

package
v0.0.0-...-9f71dab Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

View Source
const (
	//KeyNode represents the key values used for specifying the Node Affinity
	// based on the hostname
	KeyNode = "kubernetes.io/hostname"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Builder

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

Builder is the builder object for PV

func NewBuilder

func NewBuilder() *Builder

NewBuilder returns new instance of Builder

func (*Builder) Build

func (b *Builder) Build() (*corev1.PersistentVolume, error)

Build returns the PV API instance

func (*Builder) WithAccessModes

func (b *Builder) WithAccessModes(accessMode []corev1.PersistentVolumeAccessMode) *Builder

WithAccessModes sets the AccessMode field in PV with provided arguments

func (*Builder) WithAnnotations

func (b *Builder) WithAnnotations(annotations map[string]string) *Builder

WithAnnotations sets the Annotations field of PV with provided arguments

func (*Builder) WithCapacity

func (b *Builder) WithCapacity(capacity string) *Builder

WithCapacity sets the Capacity field in PV by converting string capacity into Quantity

func (*Builder) WithCapacityQty

func (b *Builder) WithCapacityQty(resCapacity resource.Quantity) *Builder

WithCapacityQty sets the Capacity field in PV with provided arguments

func (*Builder) WithLabels

func (b *Builder) WithLabels(labels map[string]string) *Builder

WithLabels sets the Labels field of PV with provided arguments

func (*Builder) WithLocalHostDirectory

func (b *Builder) WithLocalHostDirectory(path string) *Builder

WithLocalHostDirectory sets the LocalVolumeSource field of PV with provided hostpath

func (*Builder) WithLocalHostPathFormat

func (b *Builder) WithLocalHostPathFormat(path, fstype string) *Builder

WithLocalHostPathFormat sets the LocalVolumeSource field of PV with provided hostpath and request to format it with fstype - if not already formatted. A "" value for fstype indicates that the Local PV can determine the type of FS.

func (*Builder) WithNFS

func (b *Builder) WithNFS(server, path string, readOnly bool) *Builder

WithNFS sets the NFS volume source settings

func (*Builder) WithName

func (b *Builder) WithName(name string) *Builder

WithName sets the Name field of PV with provided value.

func (*Builder) WithNodeAffinity

func (b *Builder) WithNodeAffinity(labels map[string]string) *Builder

WithNodeAffinity sets the NodeAffinity field of PV with provided node labels

func (*Builder) WithNodeAffinityHostname

func (b *Builder) WithNodeAffinityHostname(nodeName string) *Builder

WithNodeAffinityHostname sets the NodeAffinity field of PV with provided node name

func (*Builder) WithPersistentVolumeSource

func (b *Builder) WithPersistentVolumeSource(source *corev1.PersistentVolumeSource) *Builder

WithPersistentVolumeSource sets the volume source field of PV with provided source

func (*Builder) WithReclaimPolicy

func (b *Builder) WithReclaimPolicy(reclaimPolicy corev1.PersistentVolumeReclaimPolicy) *Builder

WithReclaimPolicy sets the PV ReclaimPolicy field with provided argument

func (*Builder) WithVolumeMode

func (b *Builder) WithVolumeMode(volumeMode corev1.PersistentVolumeMode) *Builder

WithVolumeMode sets the VolumeMode field in PV with provided arguments

type Kubeclient

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

Kubeclient enables kubernetes API operations on pv instance

func NewKubeClient

func NewKubeClient(opts ...KubeclientBuildOption) *Kubeclient

NewKubeClient returns a new instance of kubeclient meant for cstor volume replica operations

func (*Kubeclient) Create

Create creates a pv in kubernetes cluster

func (*Kubeclient) Delete

func (k *Kubeclient) Delete(ctx context.Context, name string, deleteOpts *metav1.DeleteOptions) error

Delete deletes a pv instance from the kubecrnetes cluster

func (*Kubeclient) DeleteCollection

func (k *Kubeclient) DeleteCollection(ctx context.Context, listOpts metav1.ListOptions, deleteOpts *metav1.DeleteOptions) error

DeleteCollection deletes a collection of pv objects.

func (*Kubeclient) Get

Get returns a pv resource instances present in kubernetes cluster

func (*Kubeclient) List

List returns a list of pv instances present in kubernetes cluster

type KubeclientBuildOption

type KubeclientBuildOption func(*Kubeclient)

KubeclientBuildOption abstracts creating an instance of kubeclient

func WithClientSet

func WithClientSet(c *kubernetes.Clientset) KubeclientBuildOption

WithClientSet sets the kubernetes client against the kubeclient instance

func WithKubeConfigPath

func WithKubeConfigPath(path string) KubeclientBuildOption

WithKubeConfigPath sets the kubeConfig path against client instance

type ListBuilder

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

ListBuilder enables building an instance of PVlist

func ListBuilderForAPIObjects

func ListBuilderForAPIObjects(pvs *corev1.PersistentVolumeList) *ListBuilder

ListBuilderForAPIObjects builds the ListBuilder object based on PV api list

func ListBuilderForObjects

func ListBuilderForObjects(pvs *PVList) *ListBuilder

ListBuilderForObjects builds the ListBuilder object based on PVList

func NewListBuilder

func NewListBuilder() *ListBuilder

NewListBuilder returns an instance of ListBuilder

func (*ListBuilder) APIList

func (b *ListBuilder) APIList() (*corev1.PersistentVolumeList, error)

APIList builds core API PV list using listbuilder

func (*ListBuilder) Len

func (b *ListBuilder) Len() (int, error)

Len returns the number of items present in the PVCList of a builder

func (*ListBuilder) List

func (b *ListBuilder) List() (*PVList, error)

List returns the list of pv instances that was built by this builder

func (*ListBuilder) WithFilter

func (b *ListBuilder) WithFilter(pred ...Predicate) *ListBuilder

WithFilter adds filters on which the pv's has to be filtered

type PV

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

PV is a wrapper over persistentvolume api object. It provides build, validations and other common logic to be used by various feature specific callers.

func NewForAPIObject

func NewForAPIObject(obj *corev1.PersistentVolume, opts ...pvBuildOption) *PV

NewForAPIObject returns a new instance of PV

func (*PV) GetAffinitedNodeHostname

func (p *PV) GetAffinitedNodeHostname() string

GetAffinitedNodeHostname returns hostname configured using the NodeAffinity This method expects only a single hostname to be set.

The PV object will have the node's hostname specified as follows:

nodeAffinity:
  required:
    nodeSelectorTerms:
    - matchExpressions:
      - key: kubernetes.io/hostname
        operator: In
        values:
        - hostname

func (*PV) GetAffinitedNodeLabels

func (p *PV) GetAffinitedNodeLabels() map[string]string

GetAffinitedNodeLabelKeyAndValue returns label key and value configured using the NodeAffinity. This method expects only a single value to be set.

The PV object will have the node's hostname specified as follows:

nodeAffinity:
  required:
    nodeSelectorTerms:
    - matchExpressions:
      - key: kubernetes.io/hostname
        operator: In
        values:
        - hostname

func (*PV) GetPath

func (p *PV) GetPath() string

GetPath returns path configured on VolumeSource The VolumeSource can be either Local or HostPath

func (*PV) IsNil

func (p *PV) IsNil() bool

IsNil returns true if the PV instance is nil

type PVList

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

PVList is a wrapper over persistentvolume api object. It provides build, validations and other common logic to be used by various feature specific callers.

func (*PVList) Len

func (p *PVList) Len() int

Len returns the number of items present in the PVList

func (*PVList) ToAPIList

func (p *PVList) ToAPIList() *corev1.PersistentVolumeList

ToAPIList converts PVList to API PVList

type Predicate

type Predicate func(*PV) bool

Predicate defines an abstraction to determine conditional checks against the provided pvc instance

func ContainsName

func ContainsName(name string) Predicate

ContainsName is filter function to filter pv's based on the name

func IsNil

func IsNil() Predicate

IsNil is predicate to filter out nil PV instances

type PredicateList

type PredicateList []Predicate

PredicateList holds a list of predicate

Jump to

Keyboard shortcuts

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