Class PersistentVolume

  • All Implemented Interfaces:
    IPersistentVolume, IResource, IStorage, software.amazon.jsii.JsiiSerializable, software.constructs.IConstruct
    Direct Known Subclasses:
    AwsElasticBlockStorePersistentVolume, AzureDiskPersistentVolume, GCEPersistentDiskPersistentVolume

    @Generated(value="jsii-pacmak/1.56.0 (build 55e7d15)",
               date="2022-04-13T14:52:28.897Z")
    @Stability(Stable)
    public class PersistentVolume
    extends Resource
    implements IPersistentVolume, IStorage
    A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator or dynamically provisioned using Storage Classes.

    It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual Pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.

    • Constructor Detail

      • PersistentVolume

        protected PersistentVolume​(software.amazon.jsii.JsiiObjectRef objRef)
      • PersistentVolume

        protected PersistentVolume​(software.amazon.jsii.JsiiObject.InitializationMode initializationMode)
      • PersistentVolume

        @Stability(Stable)
        protected PersistentVolume​(@NotNull
                                   software.constructs.Construct scope,
                                   @NotNull
                                   String id,
                                   @Nullable
                                   PersistentVolumeProps props)
        Parameters:
        scope - This parameter is required.
        id - This parameter is required.
        props -
      • PersistentVolume

        @Stability(Stable)
        protected PersistentVolume​(@NotNull
                                   software.constructs.Construct scope,
                                   @NotNull
                                   String id)
        Parameters:
        scope - This parameter is required.
        id - This parameter is required.
    • Method Detail

      • fromPersistentVolumeName

        @Stability(Stable)
        @NotNull
        public static IPersistentVolume fromPersistentVolumeName​(@NotNull
                                                                 String volumeName)
        Imports a pv from the cluster as a reference.

        Parameters:
        volumeName - The name of the pv to reference. This parameter is required.
      • asVolume

        @Stability(Stable)
        @NotNull
        public Volume asVolume()
        Convert the piece of storage into a concrete volume.
        Specified by:
        asVolume in interface IStorage
      • bind

        @Stability(Stable)
        public void bind​(@NotNull
                         IPersistentVolumeClaim pvc)
        Bind a volume to a specific claim.

        Note that you must also bind the claim to the volume.

        Parameters:
        pvc - The PVC to bind to. This parameter is required.
      • reserve

        @Stability(Stable)
        @NotNull
        public PersistentVolumeClaim reserve()
        Reserve a `PersistentVolume` by creating a `PersistentVolumeClaim` that is wired to claim this volume.

        Note that this method will throw in case the volume is already claimed.

      • getApiObject

        @Stability(Stable)
        @NotNull
        protected org.cdk8s.ApiObject getApiObject()
        The underlying cdk8s API object.

        Specified by:
        getApiObject in class Resource
        See Also:
        base.Resource.apiObject
      • getMode

        @Stability(Stable)
        @NotNull
        public PersistentVolumeMode getMode()
        Volume mode of this volume.
      • getClaim

        @Stability(Stable)
        @Nullable
        public IPersistentVolumeClaim getClaim()
        PVC this volume is bound to.

        Undefined means this volume is not yet claimed by any PVC.

      • getMountOptions

        @Stability(Stable)
        @Nullable
        public List<String> getMountOptions()
        Mount options of this volume.
      • getStorage

        @Stability(Stable)
        @Nullable
        public org.cdk8s.Size getStorage()
        Storage size of this volume.
      • getStorageClassName

        @Stability(Stable)
        @Nullable
        public String getStorageClassName()
        Storage class this volume belongs to.