gpt4 book ai didi

kubernetes - 在 Kubernetes 中的 Pod 之间共享持久卷

转载 作者:行者123 更新时间:2023-12-02 11:29:06 26 4
gpt4 key购买 nike

我们在 Kubernetes 中有两个 pod,为了便于交流,我们将它们称为 pod1 和 pod2。我在 pod 1 上创建了 pv1 和 pvc1,它工作正常。
在我看来,文档对此场景不够清楚,或者我找不到正确的 wiki。
如何从 pod2 访问 pv1 和 pc1?

最佳答案

来自 k8s 文档:

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned by an administrator. It is a resource in the cluster just like a node is a cluster resource. PVs are volume plugins like Volumes, but have a lifecycle independent of any individual pod that uses the PV. This API object captures the details of the implementation of the storage, be that NFS, iSCSI, or a cloud-provider-specific storage system.

A PersistentVolumeClaim (PVC) is a request for storage by a user. It is similar to a pod. Pods consume node resources and PVCs consume PV resources. Pods can request specific levels of resources (CPU and Memory). Claims can request specific size and access modes (e.g., can be mounted once read/write or many times read-only).



这意味着在问题所示的场景中,如果 PodA_deployment.yaml 创建一个卷声明:
volumeMounts:
- name: myapp-data-pv-1
mountPath: /home/myappdata/mystuff

然后PodB将能够安装pv,提出如下声明:
volumes:
- name: myapp-data-pv-1
persistentVolumeClaim:
claimName: myapp-data-pvc-1

在 PodB_deployment.yaml 中。
虽然它很清楚,一旦你理解它就有意义,文档可以更好地解释它。

关于kubernetes - 在 Kubernetes 中的 Pod 之间共享持久卷,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46100922/

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