ReadWriteOnce(RWO) allows being mounted by a single node in read-write mode.ReadOnlyMany(ROX) allows being mounted by multiple nodes in read-only mode.Filesystem is the default mode if the volume mode is not defined. A valid value for volume mode can be either Filesystem or Block. Kubernetes supports two volume modes of persistent volumes. In the future, it may include attributes such as IOPS, throughput rate, etc. Currently, the capacity property attribute storage is the only resource that can be set or requested. This is set by using the capacity property of the PV. Generally, a PV will specify storage capacity.
This section describes the spec attributes of a PV configuration file, with reference to the YAML configuration file example given above. apiVersion: v1Įach PV contains a specification (spec) and status of the volume. Finally, the storage class is specified as slow, and the NFS plug-in type is used. The storage mode is Filesystem, the access mode is ReadWriteOnce, and the persistent storage volume is recycled through the Recycle recycling policy. This configuration file requires 5Gi of storage space to be provided. The following is a YAML configuration file for persistent storage volume. Persistent storage volume can be carried out through the YAML configuration file and specify which plugin type to use. The cluster administrator can map different classes to different service levels and different backend policies. A PVC volume is a request for storage, which is used to mount a PV into a Pod. To use this resource, it must be requested through persistent volume claims (PVC). Unlike ordinary volumes, PV is a resource object in a Kubernetes cluster creating a PV is equivalent to creating a storage resource object. PV is the way to define the storage data, such as storage classes or storage implementations. In this article, you will learn more about what persistent volumes are and how best to use them. The PV is an API object that captures the implementation details of a system, such as NFS, iSCSI, or other cloud storage systems. Just like the nodes in a cluster, PV is a resource in the cluster.
PersistentVolume (PV for short) is part of the network storage within a cluster provided by the administrator. If you need to store data within Kubernetes, chances are you will be using persistent volumes. Kubernetes uses a highly abstract storage model for retaining data, allowing users to allocate and use volumes for containers in Pods without knowing the storage details. So data persistence-a mechanism that keeps data even after the Pod is deleted-is required. For Pods that collect databases and logs, it is inconvenient if the disk is deleted at the same time as the Pod. Pods created by Kubernetes have readable and writable disk space inside the Pod, but deleting a Pod also deletes this disk space. When using stateful applications, care must be taken when handling data. It is quite useful in some scenarios/requirements such as a temporary cache, shared storage for multiple containers in a Pod etc.Kubernetes has many advantages among them is the ability to easily create and delete workloads as containers. Once the Pod is deleted, so is the emptyDir data. This could be NFS or cloud based storage in case of managed Kubernetes offerings such as Azure Kubernetes Service, Google Kubernetes Engine etc.Īn emptyDir volume starts out empty (hence the name!) and is ephemeral in nature i.e. Persistent - Volumes which are meant for long term storage and independent of the Pod or the Node lifecycle.they are deleted if the Pod is removed (for any reason). Ephemeral - Volumes which are tightly coupled with the Pod lifetime (e.g.Also, different containers can possibly mount a single volume at the same time. If needed, a container within the Pod can mount more than one volume into different paths in its file system. Each of these Volumes is accessible to all containers in the Pod but it's not mandatory for all the containers to mount or make use of all the volumes. data).Ī Pod can have more than one Volume declared in spec.volumes. data-volume) and specifies exactly where it wants to mount that volume within the container file system (e.g. - it points to a volume declared in spec.volumes (e.g.in this case, its points to an Azure Disk data-volume) and other (volume) specific characteristics e.g. spec.volumes - declares the available volume(s), its name (e.g.Enter fullscreen mode Exit fullscreen mode