Download as pdf or txt
Download as pdf or txt
You are on page 1of 10

Persistent Volume in

Kubernetes

Exploring Persistent Volume


K8s Storage Overview

➔ Persistent Volumes

➔ Storage Classes

➔ PersistentVolume Claims

➔ Resizing Persistent Volume


Claim
Persistent Volumes
➢ PersistentVolumes are k8s Object that apiVersion: v1
allow user to treat Storage as an Abstract kind: PersistentVolume
metadata:
Resource.
name: static-persistent-volume
spec:
➢ PV is resource in the cluster just like a node capacity:
is a cluster resource. storage: 1Gi
accessModes:
- ReadWriteMany
➢ PV uses a set of Attribute to describe the hostPath:
underlying storage resources (Disk or Cloud path: /var/tmp
Storage), which will be used to store data. storageClassName: local-storage
Storage Classes
➢ StorageClass allows K8s Administrator apiVersion: storage.k8s.io/v1
kind: StorageClass
to Specify all type of Storage Service metadata:
they offer on their Platform. name: local-storage
provisioner: kubernetes.io/no-provisioner
volumeBindingMode: WaitForFirstConsumer
apiVersion: storage.k8s.io/v1
kind: StorageClass
Storage Classes metadata:
name: slow
provisioner: kubernetes.io/aws-ebs
➢ Admin cloud create a StorageClass parameters:
type: io1
called Slow to describe inexpensive iopsPerGB: "10"
storage for general Development use. fsType: ext4

apiVersion: storage.k8s.io/v1
kind: StorageClass
➢ Admin cloud create a StorageClass metadata:
name: fast
called Fast for High I/O Operation provisioner: kubernetes.io/gce-pd
parameters:
type: pd-ssd
Applications. allowedTopologies:
- matchLabelExpressions:
- key: failure-domain.beta.kubernetes.io/zone
values:
- us-central1-a
allowVolume Expansion
➢ allowVolumeExpansion - This field can apiVersion: storage.k8s.io/v1
kind: StorageClass
accept boolean value only. metadata:
name: local-storage
provisioner: kubernetes.io/no-provisioner
➢ This is the property of StorageClass volumeBindingMode: WaitForFirstConsumer
and define whether StorageClass allowVolumeExpansion: true

supports the ability to resize after they


are created.

➢ All Cloud Disk Supports this property.


Reclaim Policy
➢ persistentVolumeReclaimPolicy - This apiVersion: v1
define, how the storage will be reused, kind: PersistentVolume
metadata:
when the PVs associated PVCs are deleted.
name: static-persistent-volume
spec:
➢ Retain - Keep all the data. This require capacity:
manual data cleanup and prepare for reuse. storage: 1Gi
accessModes:
➢ Delete - Delete underlying storage
- ReadWriteMany
resources automatically (Support for Cloud hostPath:
Resource Only). path: /var/tmp
➢ Recycle - Automatically delete all data in storageClassName: local-storage
persistentVolumeReclaimPolicy:
underlying storage. Allow PVs to be reuse.
Recycle
PersistentVolumeClaim
➢ PersistentVolumeClaim (PVC) is a apiVersion: v1
request for storage by a user. kind: PersistentVolumeClaim
metadata:
name: myclaim
➢ PVCs define a set of attribute Similar to spec:
those of PVs. accessModes:
- ReadWriteMany
resources:
➢ PVCs look for a PVs that is able to meet requests:
the criteria. If it found one, will storage: 1Gi
automatically be bound to that PV. storageClassName: local-storage
Hands On Demonstration
Thank You...
Don’t be the Same! Be Better!!!

You might also like