PersistentVolumeClaim存储卷声明结构体

PersistentVolumeClaim 结构体

// PersistentVolumeClaim is a user's request for and claim to a persistent volume
type PersistentVolumeClaim struct {
    metav1.TypeMeta
    // +optional
    metav1.ObjectMeta

    // Spec defines the volume requested by a pod author
    // +optional
    Spec PersistentVolumeClaimSpec

    // Status represents the current information about a claim。比如PVC
    // +optional
    Status PersistentVolumeClaimStatus
}

其中嵌入了结构体metav1.TypeMetametav1.TypeMetaTypeMeta描述API响应或请求中的单个对象表示的对象类型以及其API模式版本;ObjectMeta是所有持久资源必须拥有的元数据,其中包括用户必须创建的所有对象(Name, Namespace,SelfLink(将在1.21版本中移除),Labels等等);Spec字段为PersistentVolumeClaimSpec类型,用于用户定义pod所请求的卷;Status字段为PersistentVolumeClaimStatus类型,表示当前声明的状态(阶段、访问模式、资源列表、状况)。

PersistentVolumeClaimSpec结构体

// PersistentVolumeClaimSpec describes the common attributes of storage devices
// and allows a Source for provider-specific attributes
type PersistentVolumeClaimSpec struct {
    // Contains the types of access modes required。三种访问方式分别为ReadWriteOnce(RWO),ReadOnlyMany(ROX),ReadWriteMany(RWX)
    // RWO, 那么只能被挂载在某一个Kubernetes的工作节点上,当再次尝试在其他节点挂载的时候,系统会报Multi-Attach的错误(可以同一个节点上多个Pod同时读写)
    // ROX,name可以同时在多个节点上挂载且为只读
    // RMX, 那么可以同时在多个节点上挂载并被不同的Pod读写。
    // +optional
    AccessModes []PersistentVolumeAccessMode
    // A label query over volumes to consider for binding. This selector is
    // ignored when VolumeName is set
    // +optional
    Selector *metav1.LabelSelector
    // 最小的资源要求Requests和最大的资源限制Limits。如果Requests未指定且Limits已指定,那将Limits的值作为Requests的默认值
    // +optional
    Resources ResourceRequirements
    // VolumeName is the binding reference to the PersistentVolume backing this
    // claim. When set to non-empty value Selector is not evaluated
    // +optional
    VolumeName string
    // Name of the StorageClass required by the claim.
    // More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes/#class-1
    // +optional
    StorageClassName *string
    // volumeMode defines what type of volume is required by the claim. "Block","Filesystem"两种类型
    // Value of Filesystem is implied when not included in claim spec.
    // +optional
    VolumeMode *PersistentVolumeMode
    // This field can be used to specify either:
    // * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot)
    // * An existing PVC (PersistentVolumeClaim)
    // * An existing custom resource that implements data population (Alpha)
    // In order to use custom resource types that implement data population,
    // the AnyVolumeDataSource feature gate must be enabled.
    // If the provisioner or an external controller can support the specified data source,
    // it will create a new volume based on the contents of the specified data source.
    // +optional
    DataSource *TypedLocalObjectReference
}

PersistentVolumeClaimStatus结构体

// PersistentVolumeClaimStatus represents the status of PV claim
type PersistentVolumeClaimStatus struct {
    // Phase represents the current phase of PersistentVolumeClaim
    //PersistentVolumeClaimPhase定义了PV声明的阶段,分别为"Pending","Bound","Lost"。
    //其中`Pending`代表未绑定;`Bound`代表已绑定;`Lost`代表声明绑定到PersistentVolume,但是此卷已不存在且卷上所有数据已丢失。
    // +optional
    Phase PersistentVolumeClaimPhase
    // AccessModes contains all ways the volume backing the PVC can be mounted
    // +optional
    AccessModes []PersistentVolumeAccessMode
    // Represents the actual resources of the underlying volume
    // +optional
    Capacity ResourceList
    // PersistentVolumeClaimCondition类型为"Resizing","FileSystemResizePending"。"Resizing"代表一个用户用于调整pvc大小的触发器已启动。"FileSystemResizePending"代表控制器大小调整已经完成,等待节点上的文件系统大小调整中
    // +optional  
    Conditions []PersistentVolumeClaimCondition
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容