Dynamic Volume Nedir?
Açıklaması şöyle
... in a managed environment it is highly recommended to have a facility where we can create volumes on-demand. Kubernetes provides Dynamic Volumes which eliminate the need to pre-provision volumes. To enable Dynamic Volumes we have to use a Kubernetes resource known as StorageClass . This object specifies which storage provisioner is to be used and the associated parameters.
Kullanım
StorageClass tipi PersistentVolume ile birlikte kullanılır.
- provisioner mutlaka belirtilir.
- metadata.name ile belirtilen isim PersistentVolumeClaim tipinde storageClassName olarak kullanılır
Parametreler
Açıklaması şöyle
Each StorageClass contains the fields provisioner, parameters, and reclaimPolicy, which are used when a Persistent Volume belonging to the class needs to be dynamically provisioned.
Bir başka açıklama şöyle
provisioner: A StorageClass object contains a provisioner , that decides which volume plugin will be used to provision a PV. Kubernetes provides internal and external provisioners. Internal provisioners are also called “In-tree” volume plugins, which means their code is part of the core Kubernetes code and imported with the core Kubernetes binaries. We can also specify and run an external provisioner, which is also defined as Container Storage Interface(CSI).parameters: Indicate properties of the underlying storage system.reclaimPolicy: Can be either Deleteor Retain . Default is DeletevolumeBindingMode: Can be either Immediate or WaitForFirstConsumerImmediate — Immediately provisions PV after PVC is created.WaitForFirstConsumer— will delay the provisioning of a PV until a Pod using the PVC is created.
allowVolumeExpansion
Açıklaması şöyle
Resizing a Persistent Volume (PV) was very difficult prior to Kubernetes v1.11. It was an entirely manual process that involved a long list of steps, and required the creation of a new volume from a snapshot. You couldn’t just go and modify the PVC object to change the claim size.Persistent volume expansion feature was promoted to beta in Kubernetes v1.11. This feature allows users to easily resize an existing volume by editing the PersistentVolumeClaim object. Users no longer have to manually interact with the storage backend or delete and recreate PV and PVC objects to increase the size of a volume. Shrinking persistent volumes is not supported though. You can find more information, including a list of volume types supported, here.Although the feature is enabled by default, a cluster admin has to make the feature available to users by setting the allowVolumeExpansion field to true in their StorageClass object(s). Only PVCs created from a StorageClass with this setting will be allowed to trigger volume expansion.Any PVC created from this StorageClass can be edited to request more space. Kubernetes will interpret a change to the storage field as a request for more space, and will trigger an automatic volume resizing.
Örnek
Şöyle yaparız
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: annotations: storageclass.kubernetes.io/is-default-class: "true" name: gp2 parameters: fsType: ext4 type: gp2 allowVolumeExpansion: true provisioner: kubernetes.io/aws-ebs reclaimPolicy: Delete volumeBindingMode: Immediate
minikube Kullanımı
Örnek
minikube ile şöyle yaparız
kind: StorageClassapiVersion: storage.k8s.io/v1metadata:name: fastprovisioner: k8s.io/minikube-hostpathparameters:type: pd-ssd
Örnek
Şöyle yaparız
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: local-storage provisioner: kubernetes.io/no-provisioner volumeBindingMode: WaitForFirstConsumer allowVolumeExpansion: true reclaimPolicy: Delete
Google Kullanımı
Örnek
Şöyle yaparız. Burada provisioner belirtiliyor ayrıca name olarak SSD olduğundan fast deniliyor
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: fast provisioner: kubernetes.io/gce-pd parameters: type: pd-ssd
Örnek
Açıklaması şöyle
For example, to use a SSD disk provided by Google Kubernetes Engine, create the following StorageClass:
Örnek
Bir StorageClass yaratırız. Şöyle yaparız. Burada provisioner belirtiliyor.
apiVersion: storage.k8s.io/v1kind: StorageClassmetadata:name: my-classprovisioner: kubernetes.io/gce-pdparameters:type: pd-ssd
PersistentVolumeClaim yaratırız. Şöyle yaparız
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: my-pvc spec: accessModes: - ReadWriteOnce storageClassName: my-class resources: requests: storage: 30Gi
AWS EBS Kullanımı
Açıklaması şöyle
... for AWS EBS, there are various types of EBS volumes (gp2 , gp3 , io1 , io2 , etc). And also various configurations can be done, for example — enabling encryption, specifying minimum IOPS, and minimum throughput for an EBS volume.
Örnek
Şöyle yaparız
kind: StorageClass apiVersion: storage.k8s.io/v1 metadata: name: gp2 annotations: storageclass.kubernetes.io/is-default-class: "true" provisioner: kubernetes.io/aws-ebs parameters: type: gp2 fsType: ext4
Örnek
Şöyle yaparız
apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: gp2-standard provisioner: kubernetes.io/aws-ebs # Internal-provisioner parameters: type: gp2 reclaimPolicy: Retain volumeBindingMode: Immediate
Örnek
Şöyle yaparız
--- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: gp2-standard provisioner: ebs.csi.aws.com parameters: type: gp2 volumeBindingMode: Immediate reclaimPolicy: Retain --- apiVersion: storage.k8s.io/v1 kind: StorageClass metadata: name: io2-encrypted provisioner: ebs.csi.aws.com parameters: type: io2 iopsPerGB: "3000" encrypted: "true" volumeBindingMode: WaitForFirstConsumer reclaimPolicy: Delete
Hiç yorum yok:
Yorum Gönder