T
T
TyzhSysAdmin2019-05-07 21:52:58
linux
TyzhSysAdmin, 2019-05-07 21:52:58

Multiple Claims per Persistent Volumes?

Greetings friends.
I got my hands on poking Kubernetes with a stick, but for now, he beat me with a log :)
I make such a config for creating volumes, that is, one PersistentVolume and I want to attach a pair of PersistentVolumeClaim to it.

# Add persistent data dir
kind: PersistentVolume
apiVersion: v1
metadata:
  name: persistent-data
  labels:
    type: local
spec:
  storageClassName: persistent-data
  capacity:
    storage: 500Gi
  accessModes:
    - ReadWriteMany
  persistentVolumeReclaimPolicy: Retain
  hostPath:
    path: "/mnt/kubernetes"


---
# Add persistent data dir for Bind 
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: bind-dns-data
spec:
  storageClassName: persistent-data
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 500Mi

---
# Add persistent data dir for Zabbix 
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
  name: zabbix-data
spec:
  storageClassName: persistent-data
  accessModes:
    - ReadWriteMany
  resources:
    requests:
      storage: 20Gi

As a result, bind-dns-data is bound normally and works, and in describe zabbix-data we see
storageclass.storage.k8s.io "persistent-data" not found

Having smoked a little on the Internet and offdocs, as I understand it, two PersistentVolumeClaim cannot be tied to one PersistentVolume, which slightly broke my idea of ​​\u200b\u200bthe world :)
Actually two questions:
1. Is it really impossible or are my hands crooked?
2. Why is there a parameter for PersistentVolumeClaim
requests:
      storage: 20Gi

if we limit PersistentVolumeClaim to this parameter for PersistentVolume, and if it is impossible to chain several PersistentVolumeClaim, then this parameter somehow loses its meaning or am I not catching up with something and do not see the script?
Thanks :)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
D
Dmitry Shitskov, 2019-05-07
@POS_troi

The bottom line is that PVs are static entities.
PVs are created manually and reflect the maximum physical amount that can be provided (actually, how much the administrator has decided to provide).
A PVC is essentially a request for a PV. Kubernetes will try to find a PV that matches the specified parameters - in your case, it will look for a free PV with a size of 20Gi or more. As soon as one is found, a PV-PVC link will be created - i.e. while the Claim is in effect, other pods will not be able to claim the same PV .
However, multiple pods can share the same PVC.
You may not have created a StorageClass with that name

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question