简体   繁体   English

如何将 docker 卷传输到 azure 中的 kubernetes 卷?

[英]How to transfer docker volumes to kubernetes volumes in azure?

I'm trying to apply kubernetes on one of my applications, and my app is using docker volumes and saves data in there.我正在尝试在我的一个应用程序上应用 kubernetes,我的应用程序正在使用 docker 卷并将数据保存在那里。 When I'm applying the kubernetes on that app it won't save any data from the docker volumes obviously and it just needs kubernetes volumes, thing is, I have my data inside the docker volumes and I need to transfer it to a kubernetes volume, and all that is running in azure and since kubernetes interfaces with azure I figured there should be a way to automate this only I couldn't find how to do that.当我在该应用程序上应用 kubernetes 时,它显然不会保存 docker 卷中的任何数据,它只需要 kubernetes 卷,事实是,我的数据位于 docker 卷中,我需要将其传输到 kubernetes 卷,并且所有这些都在 azure 中运行,并且由于 kubernetes 与 azure 接口,我认为应该有一种方法可以自动执行此操作,但我找不到如何做到这一点。

If someone can help with this ill be very thankful.如果有人能帮助解决这个问题,我将不胜感激。

To transfer the data in the docker volume to Azure Kubernetes volumes, the way I can think of is that transfer the data in the docker volumes to Azure file share, and then mount the file share to the Kubernetes volumes.要将docker卷中的数据传输到Azure Kubernetes卷,我能想到的方法是将docker卷中的数据传输到Azure文件共享,然后将文件共享挂载到Kubernetes卷。

The best way is that mount the Azure file share to the machine where the docker server in at the beginning, and then create the volumes in the mount path and use the volumes for your application in the docker.最好的方法是将 Azure 文件共享挂载到一开始 docker 服务器所在的机器上,然后在挂载路径中创建卷并在 docker 中为您的应用程序使用这些卷。 When you deploy the application in Azure Kubernetes, mount the file share to its volumes.在 Azure Kubernetes 中部署应用程序时,将文件共享装载到其卷。

I do not think there are the interfaces in Azure Kubernetes to automate transfer the data from docker volumes to AKS volumes.我认为 Azure Kubernetes 中没有自动将数据从 docker 卷传输到 AKS 卷的接口。

When I'm applying the kubernetes on that app it won't save any data from the docker volumes obviously and it just needs kubernetes volumes.当我在该应用程序上应用 kubernetes 时,它显然不会从 docker 卷中保存任何数据,它只需要 kubernetes 卷。

This is not fully true, as @Charles Xu mentioned, as long as your Docker containers use 'Azure File Storage' backed Volumes, you can seamlessly mount the same data volumes (Azure File Storage) as a Persistence Volumes in Azure Kubernetes Service (one of two types of data storage supported by AKS).这并不完全正确,正如@Charles Xu 提到的那样,只要您的 Docker 容器使用“Azure 文件存储”支持的卷,您就可以无缝安装相同的数据卷(Azure 文件存储)作为 Azure Kubernetes 服务中的持久性卷(一个AKS支持的两种数据存储类型)。

Taking into account you are running currently your Docker containers on-premise environment, use can use Docker Volume Driver for Azure File Storage to start pushing your data to Azure (check demo here ), or for Swarm Cluster in Azure use Cloudstor .考虑到您当前正在本地运行 Docker 容器,可以使用Docker Volume Driver for Azure File Storage开始将数据推送到 Azure( 在此处查看演示),或者对于Azure 中的 Swarm Cluster使用Cloudstor

According to the kubernetes documentation: https://kubernetes.io/docs/concepts/storage/volumes/根据 kubernetes 文档: https ://kubernetes.io/docs/concepts/storage/volumes/

Docker volumes and Kubernetes volumes are different and work differently. Docker volumesKubernetes volumes不同且工作方式不同。

When you create your PVC or it is dynamically created for you, mount it into your pod and copy the data into it using:当您创建 PVC 或为您动态创建它时,将其挂载到您的 pod 中并使用以下命令将数据复制到其中:

kubectl cp

Your app will automatically start storing data in the volume.您的应用程序将自动开始在卷中存储数据。

Docker volumes are just directories on disk and you can't simply map them to the Kubernetes volume Docker 卷只是磁盘上的目录,您不能简单地将它们映射到 Kubernetes 卷

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM