首页 > 解决方案 > 从 Kubernetes 中的快照创建 Google 永久性磁盘

问题描述

我需要在 Kubernetes 中具有非常大(700GB)只读数据集的多个节点上运行 pod。我尝试使用 readonlymany,但它在多节点设置中失败,而且通常非常不稳定。

pod 有没有办法从快照创建一个新的永久磁盘,将其附加到 pod,并在 pod 被销毁时将其销毁?这将允许我偶尔使用新数据更新快照。

标签: kubernetesgoogle-kubernetes-enginegce-persistent-disk

解决方案


您可以使用 GCP 上的现有映像手动配置永久性磁盘:

gcloud beta compute disks create --size=500GB --image=<snapshot-name>  my-data-disk

然后在你的 pod 上使用它:

apiVersion: v1
kind: Pod
metadata:
  name: test-pd
spec:
  containers:
  - image: k8s.gcr.io/test-webserver
    name: test-container
    volumeMounts:
    - mountPath: /test-pd
      name: test-volume
  volumes:
  - name: test-volume
    # This GCE PD must already exist.
    gcePersistentDisk:
      pdName: my-data-disk
      fsType: ext4

GCE 存储类不支持快照,所以很遗憾,你不能用 PVC 来做。更多信息在这里

希望能帮助到你。


推荐阅读