gpt4 book ai didi

kubernetes - 持久卷和持久卷声明如何在 Kubernetes 中相互绑定(bind)

转载 作者:行者123 更新时间:2023-12-02 11:55:10 24 4
gpt4 key购买 nike

我正在努力在 Kubernetes 中创建持久性卷和持久性卷声明。以下配置都工作正常,我能够将数据存储在持久卷存储路径中。
我创建了持久性卷

apiVersion: v1
kind: PersistentVolume
metadata:
name: pv-vol
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 1Gi #Size of the volume
accessModes:
- ReadWriteOnce #type of access
hostPath:
path: "/mnt/data" #host location
---
和持久性卷声明:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pv-claim
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
在这里,上述配置文件中的持久性卷和持久性卷声明之间没有联系。两者如何相互绑定(bind)。
Persistence volume & persistence volume claim
说在deployment.yml中,我们可以指出持久化卷声明的名称。这样POD -> PVC -> PV -> 主机存储位置。
任何人都可以帮助我了解持久性卷和持久性卷声明如何通过上述配置文件相互绑定(bind)。

最佳答案

简而言之,PV 和 PVC 之间的绑定(bind)由匹配 capacity 决定。和 accessModes .既然你有 1GiReadWriteOnce在 PV 和 PVC 中,绑定(bind)都是成功的。
来自文档 here

A user creates, or in the case of dynamic provisioning, has alreadycreated, a PersistentVolumeClaim with a specific amount of storagerequested and with certain access modes. A control loop in the masterwatches for new PVCs, finds a matching PV (if possible), and bindsthem together. If a PV was dynamically provisioned for a new PVC, theloop will always bind that PV to the PVC. Otherwise, the user willalways get at least what they asked for, but the volume may be inexcess of what was requested. Once bound, PersistentVolumeClaim bindsare exclusive, regardless of how they were bound. A PVC to PV bindingis a one-to-one mapping, using a ClaimRef which is a bi-directionalbinding between the PersistentVolume and the PersistentVolumeClaim.

Claims will remain unbound indefinitely if a matching volume does notexist. Claims will be bound as matching volumes become available. Forexample, a cluster provisioned with many 50Gi PVs would not match aPVC requesting 100Gi. The PVC can be bound when a 100Gi PV is added tothe cluster

关于kubernetes - 持久卷和持久卷声明如何在 Kubernetes 中相互绑定(bind),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62977038/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com