如何将数据从 Google Cloud VM 迁移到 Google Kubernetes Engine?

How to migrate data from Google Cloud VM to Google Kubernetes Engine?

我是 运行 Cloud VM 上的 JupyterHub,但由于某些原因,我现在无法访问 VM 上的 JupyterHub 运行。我不想解决当前 JupyterHub 的问题,而是想在我们的 Google Kubernetes Engine 上迁移 JupyterHub,所以我使用 zero-to-jupyterhub-k8s.

在 Google Kubernetes Engine 上安装了另一个 JupyterHub

现在一切正常 运行 但我想将保存在旧 JupyterHub VM 上的数据迁移到我的新 JupyterHub。新的 JupyterHub 使用 Persistent Volume 作为每个 pods 用户的存储。有人可以告诉我该怎么做吗?

将此答案发布为社区 Wiki 以获得更好的可见性,并添加一些额外的资源,以便在遇到类似情况时提供帮助。

问题中描述的问题已通过将用户数据复制到 GCS 存储桶然后将数据装载到用户 pods 解决,如评论中所述:

I solved this issue by copying the data from the VM to Google Cloud Storage and then mounted the GCS Bucket on the user pods in JupyterHub on Google Kubernetes Engine.

安装指南zero-to-jupyterhub-k8s

有关将 GCS 存储桶安装到 Kubernetes pod 的资源:


引用 Github 页面:

Disclaimer!

The big catch is that for this to work, the container has to be built with gcsfuse. The Dockerfile includes a base build for debian jessie.

The most note worthy parts of the configuration are the following:

securityContext:
 privileged: true
 capabilities:
   add:
     - SYS_ADMIN

For the container to have access to /dev/fuse it has to run with SYS_ADMIN capabilities.

lifecycle:
 postStart:
   exec:
     command: ["gcsfuse", "-o", "nonempty", "test-bucket", "/mnt/test-bucket"]
 preStop:
   exec:
     command: ["fusermount", "-u", "/mnt/test-bucket"]