我可以跨多个服务器协调Chef的部署资源的回滚吗?

时间:2022-12-20 15:26:00

I'm moving from Capistrano to Chef to deploy a Rails app (with deploy_revision), and an issue of best practice (or common practice) is unclear to me. I haven't found much through Googling around.

我从Capistrano转到Chef来部署Rails应用程序(带有deploy_revision),我不清楚最佳实践(或通用实践)的问题。我通过谷歌搜索没有找到太多。

With Capistrano and the "push" model, when deploying an application across a number of servers, it's straightforward to recognize when there has been a deployment failure and to rollback the deployment across all servers at once. Capistrano also puts up a maintenance page on each app server, then doesn't take that maintenance page down unless I've either successfully deployed to all servers or rolled back the deployment.

使用Capistrano和“push”模型,在跨多个服务器部署应用程序时,很容易识别何时发生了部署失败,并同时在所有服务器上回滚部署。Capistrano还在每个应用服务器上建立了一个维护页面,然后不会删除维护页面,除非我已经成功地部署到所有服务器或回滚部署。

With Chef and the "pull" model, each server may be fetching its updates at a slightly different time. I might wind up with the database server updating the application code and running database migrations several minutes earlier than the application servers. So I really don't have a great way of identifying a failure and ensuring that the build is rolled back to the last successful deployed version (on all servers).

使用Chef和“pull”模型,每个服务器可能在不同的时间获取更新。最后,数据库服务器可能会更新应用程序代码,并比应用服务器早几分钟运行数据库迁移。因此,我真的没有一个很好的方法来识别失败并确保构建回滚到最后一个成功部署的版本(在所有服务器上)。

I know that I have some options here:

我知道我有一些选择:

  1. Don't daemonize chef-client. Run it nightly or hourly with cron. (I still can't roll back across all of my servers in the event that some are successful and just one hits a problem.)
  2. 不要daemonize chef-client。每晚或每小时都和克伦一起跑步。(如果有些服务器成功了,只有一个出现问题,我仍然无法在所有服务器上回滚。)
  3. Don't daemonize chef-client. Don't use deploy_revision. Run it via knife ssh or capistrano-chef. (I am now back to a "push" model instead of a "pull" model, which is part of the appeal of Chef.)
  4. 不要daemonize chef-client。不要使用deploy_revision。通过刀ssh或capistrand -chef运行它。(我现在回到了“推”模式,而不是“拉”模式,这是大厨的魅力所在。)
  5. Daemonize chef-client and write custom recipes that talk to each other. (Not enthusiastic about it.)
  6. 妖魔化chef-client和编写自定义的食谱,彼此交谈。(不热情。)
  7. Relax. Don't worry about it. Let the errors happen and then fix them. (Not thrilled here, either.)
  8. 放松。别担心。让错误发生,然后修复它们。(这里不激动。)

I could start building any of these, but before I invest a lot of time in building, I was hoping to learn what has worked for large deployments in the field. What have you done?

我可以开始构建其中的任何一个,但在我投入大量时间构建之前,我希望了解在该领域的大型部署是如何工作的。你做了什么?

2 个解决方案

#1


3  

Pull is suited to addressing the problem of configuration drift. For deployment on demand (and potential rollback), push is better. Check these out (I haven't used them):

拉力适用于解决配置漂移问题。对于按需部署(以及潜在回滚),push会更好。看看这些(我还没用过):

https://github.com/etsy/deployinator

https://github.com/etsy/deployinator

http://www.rackspace.com/blog/rackspace-open-sources-dreadnot/

http://www.rackspace.com/blog/rackspace-open-sources-dreadnot/

#2


1  

I've deployed ROR apps via chef's deploy_revision strategy with a bit of success. The simplest thing to do to overcome the timing-control limitations of the pull strategy is to write a deploy script that boils down to:

我通过chef的deploy_revision策略部署了ROR应用,并取得了一些成功。要克服拉取策略的时间控制限制,最简单的方法是编写一个部署脚本,它可以归结为:

  • Stop chef-client (To ensure the daemon isn't processing things)
  • 停止ch -client(确保守护进程不处理事务)
  • Run chef-client manually (this will also restart the daemon)
  • 手动运行chefr -client(这也将重新启动守护进程)

or if you're lazy, just run chef-client and don't worry about the daemon.

或者如果您很懒,只运行chefr -client,不要担心守护进程。

Then use knife-ssh to execute these commands on the applicable nodes. The end result is that you have all your deploy-related config managed by chef but you can fire off a deploy on an as-needed basis.

然后使用knife-ssh在适用的节点上执行这些命令。最终的结果是您拥有由chef管理的所有与部署相关的配置,但是您可以根据需要启动部署。

For bonus points, package all this up in a Jenkins task. You'll need to configure jenks as a chef client, and make a "Deploy to Staging" task inside your app's project. Now you can click to run the task and your non-chef-speaking teammates can do deploys easily. And for even more bonus points, setup jenkins to auto-deploy after a successful build!

为了获得额外的积分,请将所有这些打包到Jenkins的任务中。您需要将jenks配置为chef客户端,并在应用程序的项目中进行“部署到登台”任务。现在,您可以单击以运行任务,您的非说chef的队友可以轻松地进行部署。而且,为了获得更多的积分,设置jenkins在成功构建后自动部署!

#1


3  

Pull is suited to addressing the problem of configuration drift. For deployment on demand (and potential rollback), push is better. Check these out (I haven't used them):

拉力适用于解决配置漂移问题。对于按需部署(以及潜在回滚),push会更好。看看这些(我还没用过):

https://github.com/etsy/deployinator

https://github.com/etsy/deployinator

http://www.rackspace.com/blog/rackspace-open-sources-dreadnot/

http://www.rackspace.com/blog/rackspace-open-sources-dreadnot/

#2


1  

I've deployed ROR apps via chef's deploy_revision strategy with a bit of success. The simplest thing to do to overcome the timing-control limitations of the pull strategy is to write a deploy script that boils down to:

我通过chef的deploy_revision策略部署了ROR应用,并取得了一些成功。要克服拉取策略的时间控制限制,最简单的方法是编写一个部署脚本,它可以归结为:

  • Stop chef-client (To ensure the daemon isn't processing things)
  • 停止ch -client(确保守护进程不处理事务)
  • Run chef-client manually (this will also restart the daemon)
  • 手动运行chefr -client(这也将重新启动守护进程)

or if you're lazy, just run chef-client and don't worry about the daemon.

或者如果您很懒,只运行chefr -client,不要担心守护进程。

Then use knife-ssh to execute these commands on the applicable nodes. The end result is that you have all your deploy-related config managed by chef but you can fire off a deploy on an as-needed basis.

然后使用knife-ssh在适用的节点上执行这些命令。最终的结果是您拥有由chef管理的所有与部署相关的配置,但是您可以根据需要启动部署。

For bonus points, package all this up in a Jenkins task. You'll need to configure jenks as a chef client, and make a "Deploy to Staging" task inside your app's project. Now you can click to run the task and your non-chef-speaking teammates can do deploys easily. And for even more bonus points, setup jenkins to auto-deploy after a successful build!

为了获得额外的积分,请将所有这些打包到Jenkins的任务中。您需要将jenks配置为chef客户端,并在应用程序的项目中进行“部署到登台”任务。现在,您可以单击以运行任务,您的非说chef的队友可以轻松地进行部署。而且,为了获得更多的积分,设置jenkins在成功构建后自动部署!