[英]Persistence volume change: Restart a service in Kubernetes container
I have an HTTP application (Odoo).我有一个 HTTP 应用程序(Odoo)。 This app support install/updating modules(addons) dynamically.此应用程序支持动态安装/更新模块(插件)。
I would like to run this app in a Kubernetes cluster.我想在 Kubernetes 集群中运行这个应用程序。 And I would like to dynamically install/update the modules.我想动态安装/更新模块。
I have 2 solutions for this problem.对于这个问题,我有 2 个解决方案。 However, I was wondering if there are other solutions.但是,我想知道是否还有其他解决方案。
Solution 1:解决方案1:
Advantages : I can manage the docker image version and restart an image if something happens优点:我可以管理 docker 映像版本,如果发生问题,我可以重新启动映像
Drawbacks : This solution is not bad for production however the list of all custom module repositories should all be included in the docker file.缺点:这个解决方案对生产来说还不错,但是所有自定义模块存储库的列表都应该包含在 docker 文件中。 Suppose that I have two custom modules each in its repository a change to one of them will lead to a rebuild of the whole docker image.假设我在其存储库中有两个自定义模块,对其中一个的更改将导致整个 docker 映像的重建。
Solution 2:解决方案2:
Advantages : Small changes don't trigger image build.优点:小的更改不会触发图像构建。 We don't need to recreate the pods each time.我们不需要每次都重新创建 pod。
Drawbacks : Controlling the versions of each update is difficult (I don't know if we have version control for persistent volume in Kubernetes).缺点:控制每次更新的版本很困难(我不知道我们是否对 Kubernetes 中的持久卷进行版本控制)。
Questions:问题:
odoo --update "module_name"
.对于这两种方法,都应该执行一个命令,以便将模块更改考虑在内odoo --update "module_name"
。 This command should include the module name.此命令应包含模块名称。 For solution 2, How to execute a command in each pod?对于解决方案 2,如何在每个 pod 中执行命令?Thank you very much.非常感谢。
You will probably be better off with your first solution.您的第一个解决方案可能会更好。 Specially if you already have all the toolchain to rebuild and deploy images.特别是如果您已经拥有所有工具链来重建和部署图像。 It will be easier for you to rollback to previous versions and also to troubleshoot (since you know exactly which version is running in each pod).您可以更轻松地回滚到以前的版本并进行故障排除(因为您确切知道每个 pod 中运行的是哪个版本)。
There is an alternative solution that is sometime used to provision static assets on web servers: You can add an emptyDir volume and a sidecar container to the pod.有一个替代解决方案有时用于在 web 服务器上配置 static 资产:您可以将 emptyDir 卷和 sidecar 容器添加到 pod。 The sidecar pull the changes from your plugins repositories into the emptyDir at fixed interval. Sidecar 以固定的时间间隔将插件存储库中的更改拉入 emptyDir。 Finally your app container, sharing the same emptyDir volume will have access to the plugins.最后,您的应用程序容器共享相同的 emptyDir 卷将可以访问插件。
In any case running the command to update the plugin is going to be complicated.在任何情况下,运行更新插件的命令都会很复杂。 You could do it at fixed interval but your app might not like it.您可以以固定的时间间隔执行此操作,但您的应用程序可能不喜欢它。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.