20 Mart 2022 Pazar

Kubernetes kind : PersistentVolumeClaim - Ne Kadar Yer İstiyoruz

Giriş
Açıklaması şöyle.
Creating a persistent volume is easy. Create a .yaml file with kind: PersistentVolume and a suitable host path, and you can use kubectl -f your-pv.yaml apply to provision the resources. You can also use kubectl get pv to see a list of all Persistent Volumes that have been spooled up. 

Persistent Volume Claim is just as easy to create, only this time you use kind: PersistentVolumeClaim and identify the PV name.

On an added note, both the Persistent Volume and the Persistent Volume Claim needs to be deleted manually when you destroy a pod. If you no longer need the data stored in your PVs, use kubectl delete pvc pvc-name and kubectl delete pv pv-name to destroy the respective resources. 
Bazı Hatalar
Bir PV'ye sadece tek bir PVC bağlanabilir. Açıklaması şöyle
You have 3 persistent volumes and 3 pods claiming each. One PV can’t be claimed by more than one pod. Since you are using NFS as backend, you can use dynamic provisioning of persistent volumes.
storageClassName Alanı Varsa - Otomatik Yaratılır

storageClassName Alanı Yoksa
Açıklaması şöyle. Bu alanı yoksa varsayılan bir provisioner devreye girer ve bize disk yeri verir.
Remember that omitting the storageClassName field causes the default storage class to be used, whereas explicitly setting the field to "" disables dynamic provisioning and causes an existing volume to be selected and bound to the claim.
- Eğer selector alanı belirtilmişse "Static Persistent Volume" kullanılır
Açıklaması şöyle
accessModes — Same as PV.

resources —In this field, a pod can ask for specific amounts of storage resources.

selector — A claim with a selector attempts to match existing, unclaimed, and available PV. PVC with selector always claims the PV that has matchLabels and accessModes exact match with each other.
Şeklen şöyle
Selector şeklen şöyle



Örnek - selector
Şöyle yaparız
#PVC without selector
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 50Mi
---
#PVC with selector
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: myclaim
spec:
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 70Mi
  selector:
    matchLabels:
      storage-tier: standard

Örnek - storageClassName Yok
Şöyle yaparız. Bu durumda varsayılan storageClassName kullanılır
apiVersion: v1
kind: PersistentVolumeClaim metadata: name: mongodb-pvc-default spec: #A resources: #A requests: #A storage: 1Gi #A accessModes: #A - ReadWriteOnce #A
Açıklaması şöyle
#A Only the minimum size and access modes are specified. The storageClassName field is not set.

This PersistentVolumeClaim manifest contains only the storage size request and the desired access mode, but no storageClassName field, so the default storage class is used.

Hiç yorum yok:

Yorum Gönder

Cluster Propotional Autoscaler - ReplicaSet Ekler/Siler

Giriş Açıklaması şöyle CPA aims to horizontally scale the number of Pod replicas based on the cluster’s scale. A common example is DNS ser...