kubernetes - Kubernetes local/csi PV 内容是否同步到新节点?

标签 kubernetes persistent-storage

根据 the documentation :

A PersistentVolume (PV) is a piece of storage in the cluster that has been provisioned ... It is a resource in the cluster just like a node is a cluster resource...

所以我正在阅读所有当前可用的 plugins对于 PV,我知道对于第 3 方/集群外存储,这无关紧要(例如,将数据存储在 EBS、Azure 或 GCE 磁盘中),因为在集群中添加或删除节点时没有影响或影响很小.但是,有不同的,例如(忽略 hostPath,因为它仅适用于单节点集群):

  • 犯罪嫌疑人
  • 本地

(至少从我在文档中读到的)不需要第 3 方供应商/软件。

但是also :

... local volumes are subject to the availability of the underlying node and are not suitable for all applications. If a node becomes unhealthy, then the local volume becomes inaccessible by the pod. The pod using this volume is unable to run. Applications using local volumes must be able to tolerate this reduced availability, as well as potential data loss, depending on the durability characteristics of the underlying disk.

The local PersistentVolume requires manual cleanup and deletion by the user if the external static provisioner is not used to manage the volume lifecycle.

用例

假设我有一个带有单个 local PV 的单节点集群,我想向该集群添加一个新节点,因此我有 2 节点集群(为简单起见,数量较少)。

来自已存在的 local PV 的数据是否会被 1:1 复制到新节点中,就像有一个 PV 有 2 个冗余节点一样,还是严格绑定(bind)到现有节点?

如果无法将现有 PV 从 1 个节点调整为 2 个节点,是否可以创建一个新的 PV(从头开始创建),以便在集群上的 2 个以上节点之间进行 1:1 复制?

或者,如果不是,那么不使用第 3 方集群外解决方案的正确方法是什么?使用 csi 是否会导致整体方法发生任何变化,或者它是否与冗余相同,只是引擎盖下的不同“引擎”?

最佳答案

Can a new PV be created so it's 1:1 replicated between 2+ nodes on the cluster?

根本没有复制任何标准卷类型。如果您可以使用支持 ReadWriteMany 访问(最适合 NFS)的卷类型,那么多个 pod 可以同时使用它,但您必须运行匹配的 NFS 服务器。

您引用的卷类型:

  • hostPath 是 pod 恰好在其上运行的节点上的目录。它不是任何特定节点上的目录,因此如果在不同节点上重新创建 pod,它将引用同一目录但在新节点上,可能具有不同的内容。除了基本的测试场景外,我不确定 hostPath PersistentVolume 何时会有用。

  • local 是特定节点上的目录,或者至少遵循节点亲和性约束。 Kubernetes 知道并非所有存储都可以挂载到每个节点上,因此这会自动限制 pod 在具有目录的节点上运行(假设该节点仍然存在)。

  • csi 是一种极其通用的扩展机制,因此您可以运行不在链接列表中的存储驱动程序。存储后端的 CSI 版本可能比树内版本更好地支持某些功能。 (我熟悉 AWS:EBS CSI driver 支持快照和调整大小;EFS CSI driver 可以动态配置 NFS 目录。)

在本地测试集群的特定情况下(例如,使用 kind ),使用 local 卷将限制 pod 在具有数据的节点上运行,这比使用更健壮hostPath 卷。不过,它不会复制数据,因此如果删除包含数据的节点,数据也会随之消失。

关于kubernetes - Kubernetes local/csi PV 内容是否同步到新节点?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67654530/

相关文章:

kubernetes - 监视每个 namespace 的资源

AWS 主节点上的 Kubernetes 问题

C# .NET - 存储一些非常小规模的持久信息的方法?

mongodb - 如何使用 NFS 部署具有持久卷的单实例 mongodb

c# - 更新操作缓存并保持不同步

kubernetes - Kubernetes:配置快照

docker - Kubernetes中的驱动程序和容器运行时之间有什么区别?

kubernetes - 在 helm 中的替代依赖项之间进行选择

local-storage - IndexedDB 在 Chrome 应用程序中的持久性如何

iphone - 更新应用程序后,uitableview 中的数据不会被删除