Giriş
1. Dynamic Provisioning kullanıyorsak artık bir PV yaratmaya gerek yok. Bu otomatik olarak yaratılacak.
2. Ancak yine de çoğu projede bir PV yaratılıyor fakat storageClassName ile Dynamic Provisioning istendiği belirtiliyor.
Şeklen şöyle
Static Provisioning vs Dynamic Provisioning
Farkı şeklen şöyle.
İlk örnekte PV hostPath ile yaratılıyor. PVC storage ve accessMode alanları ile PV'ye eşleştiriliyor. Pod claimName ile PVC'ye eşleşiyor.
İkinci örnekte PV yaratmaya gerek yok. SC yaratılıyor. PVC storageClassname ile SC ile eşleşiyor. Pod claimName ile PVC'ye eşleşiyor.
LifeCycle of Dynamically Provisioned Persistent Volumes
Açıklaması şöyle. Yani claim silinmediği müddetçe veri durur.
A new PersistentVolume object is created for each claim, which means that the cluster can never run out of them. Obviously, the datacentre itself can run out of available disk space, but at least there is no need for the administrator to keep recycling old PersistentVolume objects.
Örnek - PersistentVolume + storageClassName
storageClassName İsimleri
Şöyle yaparız
apiVersion: v1kind: PersistentVolumemetadata:name: mysql-pv-volumenamespace: springboot-projectlabels:type: localspec:storageClassName: manualcapacity:storage: 20GiaccessModes:- ReadWriteOncehostPath:path: "/mnt/data"---apiVersion: v1kind: PersistentVolumeClaimmetadata:name: mysql-pv-claimnamespace: springboot-projectspec:storageClassName: manualaccessModes:- ReadWriteOnceresources:requests:storage: 20Gi
Örnek - PersistentVolume + storageClassName
Şöyle yaparız
apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
name: gp2-encrypted
annotations:
# Make this storageClass as Default
storageclass.kubernetes.io/is-default-class: "true"
provisioner: ebs.csi.aws.com # Amazon EBS CSI driver
parameters:
type: gp2
encrypted: 'true' # EBS volumes will always be encrypted by default
volumeBindingMode: WaitForFirstConsumer
reclaimPolicy: Delete
mountOptions:
- debugSonra şöyle yaparız
---
#PVC definition
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ebs-claim-01
spec:
storageClassName: gp2-encrypted
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 10Gi
---
#Pod definition with PVC as a Volume
apiVersion: v1
kind: Pod
metadata:
name: webserver
spec:
containers:
- name: nginx-container
image: nginx:latest
volumeMounts:
- mountPath: "/usr/share/nginx/html"
name: test-volume
volumes:
- name: test-volume
persistentVolumeClaim:
claimName: ebs-claim-01Açıklaması şöyle
Another great thing about storage classes is that claims refer to them by name. If the storage classes are named appropriately, such as standard, fast, and so on, the persistent volume claim manifests are portable across different clusters.
Örnek - GCP standard
Şöyle yaparız
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc-demo
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 30Gi
storageClassName: standard-rwo

Hiç yorum yok:
Yorum Gönder