简体   繁体   English

持久化卷更改:在 Kubernetes 容器中重新启动服务

[英]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:

  • Include the custom modules with the app in the Docker image在 Docker 映像中包含应用程序的自定义模块
  • Every time I made a change in the custom module and push it to a git repository.每次我对自定义模块进行更改并将其推送到 git 存储库时。 Jinkins pull the changes and create a new image and then apply the new changes to the Kubernetes cluster. Jinkins 拉取更改并创建新映像,然后将新更改应用到 Kubernetes 集群。

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:

  • Have a persistent volume that contains only the custom modules.拥有一个仅包含自定义模块的持久卷。
  • If a change is made to a custom module it is updated in the persistent volume.如果对自定义模块进行了更改,它将在持久卷中更新。
  • The changes need to apply to each pod running the app (I don't know maybe doing a restart)更改需要应用于运行应用程序的每个 pod(我不知道可能会重新启动)

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:问题:

  • Is there another solution to solve this problem?有没有另一种解决方案来解决这个问题?
  • For both methods, there is a command that should be executed in order to take the module changes into consideration 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 中执行命令?
  • For solution 2 is it better to restart the app service(odoo) instead of restarting all the nodes?对于解决方案 2,重新启动应用程序服务(odoo)而不是重新启动所有节点是否更好? Meaning, if we can execute a command on each pod we can just restart the service of the app.这意味着,如果我们可以在每个 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.

相关问题 Azure Kubernetes 服务 - 持久卷/持久卷声明更改权限 - Azure Kubernetes Service - Persistent Volume / Persistent Volume Claim change permissions 在 kubernetes 的容器中运行的 Window 服务的卷挂载和环境变量访问 - Volume mount and environment variable access for a Window service running in a container in kubernetes 多个持久化卷声明可以绑定到 Kubernetes 中的同一个持久化卷吗 - Can multiple persistence volume claims bind to same persistence volume in Kubernetes kubernetes 持久化卷和持久化卷声明超出存储 - kubernetes persistence volume and persistence volume claim exceeded storage 频繁 kubernetes 容器重启 - Frequent kubernetes container restart 使用nfs网络路径作为kubernetes持久卷 - using nfs network path as a kubernetes persistence volume Kubernetes; 如何将卷挂载到容器 - Kubernetes; How a volume is mounted to a container 如何使用Kubernetes Persistence Volume动态创建EBS卷 - How to dynamically create EBS volume with Kubernetes Persistence Volume 持久卷和持久卷声明在 kubernetes 中如何相互绑定 - How persistent volume and persistence volume claim bound each other in kubernetes Kubernetes-Azure容器服务上的Windows容器与Azure文件持久卷安装有关的问题 - Kubernetes - Windows container on Azure container service issues with azure file persistent volume mount
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM