Class Volume
- java.lang.Object
-
- software.amazon.jsii.JsiiObject
-
- org.cdk8s.plus20.Volume
-
- All Implemented Interfaces:
IStorage,software.amazon.jsii.JsiiSerializable
@Generated(value="jsii-pacmak/1.56.0 (build 55e7d15)", date="2022-04-13T14:52:28.952Z") @Stability(Stable) public class Volume extends software.amazon.jsii.JsiiObject implements IStorage
Volume represents a named volume in a pod that may be accessed by any container in the pod.Docker also has a concept of volumes, though it is somewhat looser and less managed. In Docker, a volume is simply a directory on disk or in another Container. Lifetimes are not managed and until very recently there were only local-disk-backed volumes. Docker now provides volume drivers, but the functionality is very limited for now (e.g. as of Docker 1.7 only one volume driver is allowed per Container and there is no way to pass parameters to volumes).
A Kubernetes volume, on the other hand, has an explicit lifetime - the same as the Pod that encloses it. Consequently, a volume outlives any Containers that run within the Pod, and data is preserved across Container restarts. Of course, when a Pod ceases to exist, the volume will cease to exist, too. Perhaps more importantly than this, Kubernetes supports many types of volumes, and a Pod can use any number of them simultaneously.
At its core, a volume is just a directory, possibly with some data in it, which is accessible to the Containers in a Pod. How that directory comes to be, the medium that backs it, and the contents of it are determined by the particular volume type used.
To use a volume, a Pod specifies what volumes to provide for the Pod (the .spec.volumes field) and where to mount those into Containers (the .spec.containers[*].volumeMounts field).
A process in a container sees a filesystem view composed from their Docker image and volumes. The Docker image is at the root of the filesystem hierarchy, and any volumes are mounted at the specified paths within the image. Volumes can not mount onto other volumes
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class software.amazon.jsii.JsiiObject
software.amazon.jsii.JsiiObject.InitializationMode
-
Nested classes/interfaces inherited from interface org.cdk8s.plus20.IStorage
IStorage.Jsii$Default, IStorage.Jsii$Proxy
-
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description VolumeasVolume()Convert the piece of storage into a concrete volume.static VolumefromConfigMap(IConfigMap configMap)Populate the volume from a ConfigMap.static VolumefromConfigMap(IConfigMap configMap, ConfigMapVolumeOptions options)Populate the volume from a ConfigMap.static VolumefromEmptyDir(String name)An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node.static VolumefromEmptyDir(String name, EmptyDirVolumeOptions options)An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node.static VolumefromPersistentVolumeClaim(IPersistentVolumeClaim pvc)Used to mount a PersistentVolume into a Pod.static VolumefromPersistentVolumeClaim(IPersistentVolumeClaim pvc, PersistentVolumeClaimVolumeOptions options)Used to mount a PersistentVolume into a Pod.static VolumefromSecret(ISecret secret)Populate the volume from a Secret.static VolumefromSecret(ISecret secret, SecretVolumeOptions options)Populate the volume from a Secret.StringgetName()-
Methods inherited from class software.amazon.jsii.JsiiObject
jsiiAsyncCall, jsiiAsyncCall, jsiiCall, jsiiCall, jsiiGet, jsiiGet, jsiiSet, jsiiStaticCall, jsiiStaticCall, jsiiStaticGet, jsiiStaticGet, jsiiStaticSet, jsiiStaticSet
-
-
-
-
Method Detail
-
fromConfigMap
@Stability(Stable) @NotNull public static Volume fromConfigMap(@NotNull IConfigMap configMap, @Nullable ConfigMapVolumeOptions options)
Populate the volume from a ConfigMap.The configMap resource provides a way to inject configuration data into Pods. The data stored in a ConfigMap object can be referenced in a volume of type configMap and then consumed by containerized applications running in a Pod.
When referencing a configMap object, you can simply provide its name in the volume to reference it. You can also customize the path to use for a specific entry in the ConfigMap.
- Parameters:
configMap- The config map to use to populate the volume. This parameter is required.options- Options.
-
fromConfigMap
@Stability(Stable) @NotNull public static Volume fromConfigMap(@NotNull IConfigMap configMap)
Populate the volume from a ConfigMap.The configMap resource provides a way to inject configuration data into Pods. The data stored in a ConfigMap object can be referenced in a volume of type configMap and then consumed by containerized applications running in a Pod.
When referencing a configMap object, you can simply provide its name in the volume to reference it. You can also customize the path to use for a specific entry in the ConfigMap.
- Parameters:
configMap- The config map to use to populate the volume. This parameter is required.
-
fromEmptyDir
@Stability(Stable) @NotNull public static Volume fromEmptyDir(@NotNull String name, @Nullable EmptyDirVolumeOptions options)
An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node.As the name says, it is initially empty. Containers in the Pod can all read and write the same files in the emptyDir volume, though that volume can be mounted at the same or different paths in each Container. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever.
- Parameters:
name- This parameter is required.options- - Additional options.
-
fromEmptyDir
@Stability(Stable) @NotNull public static Volume fromEmptyDir(@NotNull String name)
An emptyDir volume is first created when a Pod is assigned to a Node, and exists as long as that Pod is running on that node.As the name says, it is initially empty. Containers in the Pod can all read and write the same files in the emptyDir volume, though that volume can be mounted at the same or different paths in each Container. When a Pod is removed from a node for any reason, the data in the emptyDir is deleted forever.
- Parameters:
name- This parameter is required.
-
fromPersistentVolumeClaim
@Stability(Stable) @NotNull public static Volume fromPersistentVolumeClaim(@NotNull IPersistentVolumeClaim pvc, @Nullable PersistentVolumeClaimVolumeOptions options)
Used to mount a PersistentVolume into a Pod.PersistentVolumeClaims are a way for users to "claim" durable storage (such as a GCE PersistentDisk or an iSCSI volume) without knowing the details of the particular cloud environment.
- Parameters:
pvc- This parameter is required.options-
-
fromPersistentVolumeClaim
@Stability(Stable) @NotNull public static Volume fromPersistentVolumeClaim(@NotNull IPersistentVolumeClaim pvc)
Used to mount a PersistentVolume into a Pod.PersistentVolumeClaims are a way for users to "claim" durable storage (such as a GCE PersistentDisk or an iSCSI volume) without knowing the details of the particular cloud environment.
- Parameters:
pvc- This parameter is required.
-
fromSecret
@Stability(Stable) @NotNull public static Volume fromSecret(@NotNull ISecret secret, @Nullable SecretVolumeOptions options)
Populate the volume from a Secret.A secret volume is used to pass sensitive information, such as passwords, to Pods. You can store secrets in the Kubernetes API and mount them as files for use by pods without coupling to Kubernetes directly.
secret volumes are backed by tmpfs (a RAM-backed filesystem) so they are never written to non-volatile storage.
- Parameters:
secret- The secret to use to populate the volume. This parameter is required.options- Options.
-
fromSecret
@Stability(Stable) @NotNull public static Volume fromSecret(@NotNull ISecret secret)
Populate the volume from a Secret.A secret volume is used to pass sensitive information, such as passwords, to Pods. You can store secrets in the Kubernetes API and mount them as files for use by pods without coupling to Kubernetes directly.
secret volumes are backed by tmpfs (a RAM-backed filesystem) so they are never written to non-volatile storage.
- Parameters:
secret- The secret to use to populate the volume. This parameter is required.
-
asVolume
@Stability(Stable) @NotNull public Volume asVolume()
Convert the piece of storage into a concrete volume.
-
getName
@Stability(Stable) @NotNull public String getName()
-
-