2

Is there any tool to automate blue/green deployment on cloudfoundry for node.js applications. I've tried cloudfoundry gradle plugin (https://github.com/cloudfoundry/cf-java-client/tree/master/cloudfoundry-gradle-plugin) but it requires file parameter with jar/war file which doesn't exist in node app. How do you automate blue/green deployment of node apps in cloudfoundry?

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Piotr Bochynski
  • 382
  • 2
  • 9

2 Answers2

3

The Bluemix documentation includes a brief tutorial [1] on how to affect a blue/green zero downtime deployment (also called A/B deployments). The tutorial offers two approaches. I would recommend the second, which uses 'cf map-route' and 'cf unmap-route' commands to allow you to have two versions of your app sharing a route. You deploy the new version using a route that is known only to you. Test to ensure it is behaving as expected, then, you map the original route to your new version so that the old and new versions of your app share the same route. You can then scale the old version down (to zero instances) and scale the other up after you have both versions mapped to the same route. As you scale instances down, the elastic runtime will ensure that any active requests are quiesced before terminating the instance.

This tutorial [2] by Tim Spann is also very good at explaining, and references another great source posted by Matt Stine which was great at the time it was posted, but is now a bit dated w/r/t the cf cli syntax.

Here's an example [3] of automation that we had to affect blue/green deployment of the cloudfoundry.org web app. Hopefully, you can repurpose for your needs.

Another good tutorial [4] that includes automation and describes how to integrate the blue/green deployment automation in IBM DevOps Services.

[1] https://www.ng.bluemix.net/docs/#manageapps/index-gentopic3.html#genTopProcId4

[2] http://www.cloudfoundry.rocks/blue-green-deployment-with-cloudfoundry/

[3] https://github.com/cloudfoundry/cloudfoundry.org/blob/master/publish.sh

[4] http://ryanjbaxter.com/2015/04/15/performing-zero-downtime-deployments-from-ibm-devops-services-to-bluemix/

christo4ferris
  • 4,039
  • 1
  • 17
  • 30
  • I should note that whilst I referenced Bluemix's documentation; IBM Bluemix is based on Cloud Foundry, so the guidance there is equally valid with most Cloud Foundry based offerings, and certainly with any OSS deployments of Cloud Foundry. – christo4ferris Apr 14 '15 at 00:49
  • Thanks, but question is how to **automate** blue/green deployment not how to do that. I want to have new version of application deployed withe every commit to develop branch (continuous deployment). It can happen even 3 times a day. I don't want to have manual steps there. – Piotr Bochynski Apr 14 '15 at 08:44
  • Piotr, thanks, I think I have a script somewhere that might help. – christo4ferris Apr 14 '15 at 13:47
  • Don't forget environment variables. I have to copy over three environment variables from Blue to Green (or the reverse) in order for my app to work. – Costa Michailidis Aug 13 '15 at 06:16
2

There's a community plugin for Cloud Foundry which automates blue green deployment. The source is https://github.com/bluemixgaragelondon/cf-blue-green-deploy. To use, do the following in a deploy script:

cf install-plugin blue-green-deploy -r CF-Community
cf blue-green-deploy <app_name> --smoke-test <path to test script>

(The smoke test is optional, but sensible.)

If the test script exits with a zero exit code, the plugin will remap all routes from the current live app to the new app.

Holly Cummins
  • 10,767
  • 3
  • 23
  • 25