I have been trying my hand at writing a Gradle plugin for deploying applications to Cloud Foundry and wrote about this plugin in my previous post. I have now enhanced this plugin with support for no-downtime deploys into Cloud Foundry using two approaches—an Autopilot style deployment described here and more commonly used Blue-Green style deployment described here.
To jump into the meat of the plugin, once it is configured cleanly, all you have to do is the following:
For an autopilot style:
...and for a Blue-Green deployment:
And the plugin tasks would take care of the rest.
What Is Being Solved
If you use Cloud Foundry CLI to push an application to Cloud Foundry, then existing instances of the application are stopped, replaced, and started up. This introduces a downtime for the application until the new instance of the application is up. Just to demonstrate this behavior, the following graph represents steady traffic to a website while an application is pushed to Cloud Foundry—the 30-second blip is when the new app is being started up.
Autopilot and Blue-Green Style Deployments
Autopilot and Blue-Green styles of deployment fix the issue by carefully orchestrating the deployment of an application such that the external facing route always points to a working version of the application.
The plugin now natively performs all the steps needed for these two styles of no-downtime deployments.
Here is how the same graph looks with an Autopilot style type deployment using the plugin, note that there is a slightly higher response time around the time the new application switches in. Once primed though the response times smooth out:
...and with a Blue-Green style deployment using this plugin:
1. The details about how to install and configure the plugin is available here - https://github.com/pivotalservices/ya-cf-app-gradle-plugin
2. A sample application configured with the plugin is here - https://github.com/bijukunjummen/cf-show-env