Demonstrate Blue-Green Deployments on Cloud Foundry with this simple (one Groovy file, one HTML file) Spring Boot CLI application!
-
Install the latest Spring Boot CLI.
-
Run:
$ spring run app.groovy
The application requires the latest version of the Java Buildpack, so we’ll use that from GitHub. Cloud Foundry requires unique URLs, so use the '-n' flag to define a unique HOSTNAME and add a short alphanumeric suffix.
$ $ cf push cf-scale-boot -m 512M -b https://github.com/cloudfoundry/java-buildpack -n cf-scale-boot-a123z
This application leverages the colors blue and green to demonstrate the dynamic routing and load balancing capabilities of Cloud Foundry in a Blue-Green Deployment Scenario.
-
Push the application as-is, with blue appended to the application name. Use '-n' to define a unique HOSTNAME:
$ cf push cf-bg-demo-blue -m 512M -b https://github.com/cloudfoundry/java-buildpack -n cf-bg-demo-blue-a123z
-
Map a ``zero downtime'' route to the application and use '-n' to define a unique HOSTNAME:
cf map-route cf-bg-demo-blue cfapps.io -n cf-bg-demo-a123z
Visit your application in the browser using your zero downtime route to see that it is working.
-
Modify app.groovy to use the color green (line 8):
model['color'] = 'green'
-
Push the modified application, with green appended to the application name and again use '-n' to define a unique HOSTNAME:
$ cf push cf-bg-demo-green -m 512M -b https://github.com/cloudfoundry/java-buildpack -n cf-bg-demo-green-a123z
-
Map the ``zero downtime'' route to the modified application, including the HOSTNAME suffix you added in Step 2:
cf map-route cf-bg-demo-green cfapps.io -n cf-bg-demo-a123z
Visit your application in the browser using your zero downtime route to see that the platform is load balancing between the two instances.
-
Un-map the ``zero downtime'' route from the original application, including the HOSTNAME suffix you added in Step 2:
cf unmap-route cf-bg-demo-blue cfapps.io -n cf-bg-demo-a123z
Visit your application in the browser using your zero downtime route to see that only the modified application is now in play.