Cloud Foundry CLI plugin for zero downtime deploys
Go Shell
Clone or download
Permalink
Failed to load latest commit information.
acceptance Re-order domains again to work around #71 Jul 20, 2018
coverage placeholder Apr 7, 2015
fixtures Test manifests with inheritance and when no file given Feb 15, 2017
manifest Fix typo in comment Jul 23, 2018
script Add initial release description for release automation Jul 27, 2018
test/support cf now preserves uppercase letters in routes Apr 23, 2015
.env Switch to storing version in .version file Jan 26, 2018
.gitignore Add coverage to gitignore Jul 23, 2018
.releaseDescription Add initial release description for release automation Jul 27, 2018
.version Adjust version to rc for next release (following new scheme) Jul 27, 2018
CONTRIBUTING.md Contributor instructions Nov 16, 2016
LICENSE Add Apache 2 license Jun 23, 2015
README.md Switch argument from default-delete to default-keep Jul 23, 2018
args.go Switch argument from default-delete to default-keep Jul 23, 2018
args_test.go Switch argument from default-delete to default-keep Jul 23, 2018
blue_green_deploy.go Do not delete failed apps, or diagnosis becomes too difficult Jul 23, 2018
blue_green_deploy_test.go Do not delete failed apps, or diagnosis becomes too difficult Jul 23, 2018
cf_green_blue_deploy_suite_test.go generate JUnit test output Jan 20, 2017
main.go Merge pull request #72 from bluemixgaragelondon/option-switch Jul 27, 2018
main_test.go Merge pull request #72 from bluemixgaragelondon/option-switch Jul 27, 2018
release.md Update build pipeline URL Jul 8, 2018

README.md

Blue/Green deployer plugin for CF

Introduction

cf-blue-green-deploy is a plugin for the CF command line tool that automates a few steps involved in zero-downtime deploys.

Overview

The plugin takes care of the following steps packaged into one command:

  • Pushes the current version of the app with a new name
  • Optionally runs smoke tests against the newly pushed app to verify the deployment
    • If smoke tests fail, newly pushed app gets marked as failed and left around for investigation
    • If smoke tests pass, remaps routes from the currently live app to the newly deployed app
  • Cleans up versions of the app no longer in use

How to use

  • Get the plugin from the CF Community Repository
cf add-plugin-repo CF-Community https://plugins.cloudfoundry.org
cf install-plugin blue-green-deploy -r CF-Community

In scripts, add the -f flag to install-plugin for non-interactive mode.

  • Deploy your app
cd your_app_root
cf blue-green-deploy app_name
  • Deploy with optional smoke tests
cf blue-green-deploy app_name --smoke-test <path to test script>
  • Deploy with specific manifest file
cf blue-green-deploy app_name -f <path to manifest>
  • Deploy with a hard clean-up of the 'blue' (original) app
cf blue-green-deploy app_name --delete-old-apps
  • You can also use the shorter alias
cf bgd app_name

The only argument passed to the smoke test script is the FQDN of the newly pushed app. If the smoke test returns with a non-zero exit code the deploy process will stop and fail, the current live app will not be affected.

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. The plugin supports routes under custom domains.

How to build

Before cloning the source, you may wish to set up GOPATH and a go-friendly folder hierarchy to avoid path issues. Run the following in your preferred working directory:

mkdir ./go
export GOPATH=`pwd`/go
mkdir -p go/src/github.com/bluemixgaragelondon/
cd go/src/github.com/bluemixgaragelondon/
git clone https://github.com/bluemixgaragelondon/cf-blue-green-deploy
cd cf-blue-green-deploy

Then run a build:

script/build

This will download dependencies, run the tests, and build binaries in the artefacts folder.

How to run tests

script/test

This will run the unit tests. To run the acceptance tests (which need a Cloud Foundry instance), use

script/test_acceptance

You almost certainly want to install the plugin before running the acceptance tests (to make sure the latest version of the plugin is being tested). On OS X, the command would be

script/build ; script/install ; script/test_acceptance

See instructions for releasing a project for instructions on how to setup the acceptance tests.