如何在不停机的情况下在 Bluemix 中进行部署

How can I deploy in Bluemix with no downtime

我们在 bluemix 上有一个应用程序 运行,但是每当我们停止部署该应用程序时,新版本就会 compiled/bundled 然后启动,所有这些都会导致至少 60 秒的停机时间。

我们如何在不停机的情况下进行部署?

您可以使用滚动更新来避免停机。有时也可以找到 "blue/green deployments"。基本上,您保留旧版本 运行 直到新版本出现。然后你切换过来,要么直接切换,要么过一段时间,看看新版本是否真的稳定。该技术可以与负载平衡相结合来决定路由多少流量。

我会推荐阅读其中之一:

通常称为蓝绿部署或红黑部署。基本思想是将新版本的应用程序与旧版本并排部署,测试一切正常,然后将流量切换到新版本。旧应用程序保留为备份(它最终可能会停止,因此它不会消耗内存或被删除)。

这是一个non-Bluemix-specific description of the idea and also the Bluemix documentation

使用 cf CLI 它看起来像这样:

$ cf push Blue
$ cf push Green
$ cf map-route Green mybluemix.net -n Blue
$ cf unmap-route Blue mybluemix.net -n Blue
$ cf unmap-route Green mybluemix.net -n Green

有一个用于蓝绿部署的 Cloud Foundry 插件。除了基本行为(零停机时间)外,它还支持冒烟测试等功能。它住在 https://github.com/bluemixgaragelondon/cf-blue-green-deploy

要使用它,请从 CF 社区存储库获取插件:

cf install-plugin blue-green-deploy -r CF-Community

然后部署应用(冒烟测试参数可选)

cd your_app_root
cf blue-green-deploy app_name --smoke-test <path to test script>