Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

These Kubernetes components can be finely customized thanks to a number of parameters. We briefly present the theoretical aspects concerning their personalization.

Warning
titleWarning

PersistentVolume types are implemented as plugins. Kubernetes currently supports a large number of plugins (GCEPersistentDisk, AWSElasticBlockStore, AzureDisk, NFS, CephFS, Cinder, etc.). A broad overview of the parameters that the different components can adopt is presented below. It is not certain that all plugins support all the parameters listed here.

Persistent Volume

The following parameters can be managed only if the static mode is chosen, since in the dynamic case the PVs are generated on the basis of the SC and the PVCs. The aspects concerning the PV are:

  • Capacity. A PV will have a specific storage capacity. This is set using the PV's capacity attribute. An example list of accepted values are 500K, 100M, 5G, 800Ki, 350Mi, 1Ti. The letter "i" accompanying the various SI prefixes indicates numbers on a binary basis, rather than a decimal basis (more details here).
  • Volume mode. Kubernetes supports  Filesystem (default) and Block volume modes. In the first case, a volume is mounted into Pods into a directory. In the second, volume is presented into a Pod as a block device, without any filesystem on it.  This mode is useful to provide a Pod the fastest possible way to access a volume, without any filesystem layer between the Pod and the volume.
  • Access Mode. The ways of accessing the volume are shown below. Not all providers, however, support the 3 modes listed.
    • ReadWriteOnce (RWO): the volume can be mounted as read-write by a single node;
    • ReadOnlyMany (ROX): the volume can be mounted read-only by many nodes;
    • ReadWriteMany (RWX): the volume can be mounted as read-write by many nodes.
  • Class. A PV can have a class, which is specified by setting the storageClassName attribute to the name of a SC. A PV of a particular class can only be bound to PVCs requesting that class. A PV with no storageClassName has no class and can only be bound to PVCs that request no particular class. In the static case, therefore, the class merely has the function of a label.
  • Reclaim Policy. Current  When a user is done with their volume, they can delete the PVC objects from the API that allows reclamation of the resource. The reclaim policy for a PV tells the cluster what to do with the volume after it has been released of its claim. Current reclaim policies are listed below. As in the case of access mode, policy support depends on the provider used.
    • Retain: manual reclamation;. This policy allows for manual reclamation of the resource. When the PVC is deleted, the PersistentVolume still exists and the volume is considered "released". But it is not yet available for another claim because the previous claimant's data remains on the volume.
    • Recycle. This policy performs a Recycle: basic scrub (rm -rf /thevolume/*); on the volume and makes it available again for a new claim.
    • Delete (default). It removes both the PV object from Kubernetes, as well as the associated storage asset in the external infrastructureDelete: associated storage asset  is deleted.
  • Mount Option. A Kubernetes administrator can specify additional mount options for when a PV is mounted on a node, using the mountOptions attribute. Mount options are not validated, so mount will simply fail if one is invalid. Again, not all persistent volume types support mount options.
  • Node Affinity. Kubernetes offers us the possibility to create a sub-selection of nodes, from which the volume can be accessed. Pods that use a PV will only be scheduled to nodes that are selected by the node affinity.
  • Phase. Even if it does not represent a parameter, we conclude the part on the PV with a picture regarding the possible status it can assume.
    • Available: a free resource that is not yet bound to a claim;
    • Bound: the volume is bound to a claim;
    • Released: the claim has been deleted, but the resource is not yet reclaimed by the cluster;
    • Failed: the volume has failed its automatic reclamation;

...

Code Block
languageyml
titlekube-apiserver
spec:
  containers:
  - command:
    - kube-apiserver
#   other commands.
.
.
    - --enable-admission-plugins=NodeRestriction,DefaultStorageClass

Storage Class

Each SC contains fields which are used when a PersistentVolume belonging to the class needs to be dynamically provisioned. The name of a SC object is significant, and is how users can request a particular class. Administrators set the name and other parameters of a class when first creating SC objects, and the objects cannot be updated once they are created. The aspects concerning the SC are:

  • Provisioner. It determines what volume plugin is used for provisioning PVs (the list is available on the official documentation). This field must be specified.
  • Reclaim Policy.  PVs that are dynamically created by a SC will have the reclaim policy specified in the reclaimPolicy field of the class. The possible values are the same presented in the section of the PV. PVs that are created manually (static provisioning) and managed via a SC will have whatever reclaim policy they were assigned at creation.
  • Allow Volume Expansion. PVs can be configured to be expandable (in some provisioners). This feature when set to true, allows the users to resize the volume by editing the corresponding PVC object. You can only use this feature to grow a Volume, not to shrink it.
  • Mount Options. PVs that are dynamically created by a SC will have the mount options specified in the mountOptions field of the class. If the volume plugin does not support mount options but mount options are specified, provisioning will fail.
  • Volume binding Mode.  The volumeBindingMode field controls when volume binding and dynamic provisioning should occur. There are two ways:
    • Immediate mode: volume binding and dynamic provisioning occurs once the PVC is created.
    • WaitForFirstConsumer mode: delay the binding and provisioning of a PV until a Pod using the PersistentVolumeClaim is created. Until then, the PVC waits in the pending state.
  • Parameters. Storage Classes have parameters that describe volumes belonging to the storage class. Different parameters may be accepted depending on the provisioner. When a parameter is omitted, some default is used.

Lifecycle of a volume and claim

We conclude by investigating in more detail the link between PV and PVC.