如何将卷挂载到应用程序的源代码中? [英] How to mount volume into the source code of the app?

查看:103
本文介绍了如何将卷挂载到应用程序的源代码中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有kubernetes pod,我在这里将我的应用程序源代码安装为git volume.我尝试了各种设置,以了解如何将源代码放入pod中,而git volume是我最终得到的结果.

I have kubernetes pod where I am mounting my app source code as git volume. I tried various setups for how to put the source code into the pod and git volume was the one I ended up with in the end.

但是现在我的数据有问题.我的应用程序在其中有一个文件目录(空),我需要在其中安装一个卷(保险丝).但是由于目标位于git卷上,因此我无法执行此操作.所以我想知道应该如何重新设计我的应用程序?

But now I have an issue with data. My app has a files directory in it(empty) and I need to mount a volume(fuse) in there. But since the destination is located on the git volume I cannot do this. So I am wondering how should I redesign my app?

我应该直接将应用程序的源代码构建到映像中,以便随后将数据量挂载到映像中,还是可以通过某种方式将卷中的数据装入另一个映像,从而不必进行任何调整?

Should I build the app's source code directly into the image so that I can then mount the data volume into it or is there some way I can mount volume into another so that I do not have to adjust anything?

我无法将目标目录移动到其他位置,因为它必须可由应用程序在其目录中以及从Web进行访问.

I cannot move the target directory elsewhere since it has to be accessible by the app in its directory and also from web.

推荐答案

我通常要做的是在构建镜像时将源添加到docker镜像.这是一个简单的过程,就部署而言,您始终可以将映像视为黑匣子.这样实现的是,将映像的准备与运行时的部署/更新有效地解耦为两个不同的过程.

What I usually do is add the sources to the docker image when building the image. This is a straight forward process and you can always see the images as a black box in terms of deployment. What this achieves is effectively decoupling the preparation of the image and deploying/updating at run time as two different processes.

我相信,这就是kubernetes可以通过交换完整的映像而不是试图固定容器内容,而轻松地执行滚动升级以推出新软件版本的原因.就像使用以下命令一样简单:

I believe this is the reason why kubernetes makes it easy to perform rolling upgrades for rolling out new software versions by exchanging a complete image, rather than trying to fix up the contents of a container. It is as easy as using the following command:

kubectl set image deployment/my-nginx-deployment my-nginx-image=TagXX

替换图像还可以确保清除所有碎片(例如,不断增长的日志,临时文件等),并允许您带来更多更改,而不仅仅是更改源(例如,升级服务器软件版本).

Replacing images also ensures that any debris is cleaned up (e.g. growing logs, temporary files etc.) and it allows you to bring along way more changes instead of just changing sources (e.g. upgrading server software versions).

它还允许您基于确切的映像执行测试/分阶段,而不仅仅是在可能与生产服务器不同的服务器上进行代码部署.

It also allows you to perform testing/staging based on the exact images and not only a code deployment on servers that may not be identical to production servers.

您可以在此页面上进行阅读. >.

You can read up on it at this page under Updating a Deployment.

这篇关于如何将卷挂载到应用程序的源代码中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆