如何更新 bluemix 应用程序但保持此应用程序可用?

How to update bluemix application but leaving this application available?

我有 Java Bluemix 上的 Liberty Web 应用程序。如果我需要更新它,应用程序会在几分钟内变得不可用。是否可以在不关闭它的情况下更新它?例如部署两个应用程序并在更新第一个应用程序时重新路由到第二个应用程序?

是的。目前执行此操作的最佳方法是通过以下步骤。

  1. 在 myroute.mybluemix.net
  2. 上部署原始应用程序
  3. 进行一些代码更改
  4. 在 myroute2.mybluemix.net
  5. 上部署更改的应用程序
  6. 使用 cf map-route APP_NAME DOMAIN [-n HOSTNAME] 将 myroute.mybluemix.net 映射到已更改的应用程序。原始应用程序现在有 myroute.mybluemix.net,更改后的应用程序现在有 myroute.mybluemix.net & myroute2.mybluemix.net。此时流量将在两个应用程序版本之间平均路由(假设它们具有相同数量的实例)。
  7. 使用 cf unmap-route APP_NAME DOMAIN [-n HOSTNAME] 从原始应用程序取消映射 myroute.mybluemix.net。 myroute.mybluemix.net 上的所有流量现在都将路由到更新版本。
  8. 使用 cf delete APP_NAME
  9. 删除原始应用程序
  10. (可选)使用 cf unmap-route APP_NAME DOMAIN [-n HOSTNAME]
  11. 删除 myroute2.mybluemix.net

这似乎有点啰嗦,但它会达到你想要的。

这被称为蓝绿部署,有几个 cloud foundry 插件可以做到这一点 'automatically':

Bluemix's Active Deploy service

这是新功能,目前处于测试阶段。要使该服务可用,您可以将它从 Bluemix 服务目录添加到您的 space。如果你是运行本地cf,你需要安装插件:

  cf add-plugin-repo bluemix http://plugins.ng.bluemix.net/
  cf install-plugin active-deploy -r bluemix 

一旦它可用(通过 cf 插件安装,或目录配置),并且你有路由,你可以做

cf push --no-route new-version
cf active-deploy-create old-version new-version

Cloud Foundry community-contributed plugin for blue green deployments

您可以使用 cf add-plugin-repo 车库 https://garage-cf-plugins.eu-gb.mybluemix.net/ cf install-plugin blue-green-deploy -r garage

然后,推送,

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

烟雾测试部分是可选的,但这是个好主意。