Phi*_*ide 3 kubernetes kubernetes-pvc
我正在将堆栈转换为 k8s。数据库需要持久存储。
我用过kubectl create -f pv.yaml
pv.yaml (根据@whites11的答案进行编辑):
kind: PersistentVolume
apiVersion: v1
metadata:
name: pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/nfs"
claimRef:
kind: PersistentVolumeClaim
namespace: default
name: mongo-persisted-storage
Run Code Online (Sandbox Code Playgroud)
然后,我创建一个示例 mongo 副本集。
当我查看 k8s 仪表板时,我看到错误:
PersistentVolumeClaim 未绑定:“mongo-persistent-storage-mongo-0”(重复 2 次)
在持久卷选项卡中,我看到看起来不错的卷:
我无法弄清楚下一步如何使体积索赔成功发生。
我进入 GUI 上的 PVC 页面并手动向声明中添加了一个卷(基于 @whites11 的反馈)。我可以看到 PVC 已随卷更新,但仍处于待处理状态。
意识到自从进行@whites11 建议的更改后,pod 中的原始错误消息已更改。现在是“persistentvolume“pvvolume”未找到(重复2次)”,我想我只需要弄清楚我在哪里写了pvvolume,而不是pv-volume。(或者可能是-在某个地方自动解析出来的?
您需要通过向 PVclaimRef规范添加适当的部分来手动将 PV 绑定到 PVC。
在实践中,使用您喜欢的方法编辑 PV,并添加与此类似的部分:
claimRef:
name: mongo-persisted-storag
namespace: <your PVC namespace>
Run Code Online (Sandbox Code Playgroud)
然后,您需要编辑 PVC 以绑定正确的卷,方法是在其spec部分添加以下内容:
volumeName: "<your volume name>"
Run Code Online (Sandbox Code Playgroud)
以下是有关此过程如何工作的解释:https://docs.openshift.org/latest/dev_guide/persistent_volumes.html#persistent-volumes-volumes-and-claim-prebinding
| 归档时间: |
|
| 查看次数: |
4502 次 |
| 最近记录: |