Blue-Green deployment of Pivotal Cloud Foundry

There is down time in traditional deployment process. To overcome this problem, Pivotal cloud foundry came with the concept of Blue-Green deployment. This concept is also known as Zero down time deployment. Now, we look at how do we achieve an application deployment without any down time.

Lets assume the version 1 application already running in Pivotal Cloud Foundry. Make a note of the version1 application by using cf routes command.

We have made changes on top of version 1 application and version 2 is ready to deploy. Let’s push the version2 application with temporary route by using below syntax,

cf push version_two -p version_2.jar -n versiononetemp –no-start

Let’s make a note of host names and domain name to map routes by using cf routes command. Use the map-route command to navigate version1 users to version2 application. Look at the below command,

cf map-route version_two –hostname versionone

Let’s remove version1 application existing route by using unmap-route command. Look at the below command,

cf unmap-route version_one -n versionone

Let’s remove version2 application existing route(temp route) by using below command.

cf unmap-route version_two -n versiononetemp

This complete process explains, how zero downtime / Blue-green deployment process will work.

Note: Let’s assume we have made changes in database(adding/deleting columns from a table) level between one version to another version,

  • If we follow the native queries by using JDBC/Spring JDBC, that may not cause any issues. We can follow Blue-Green deployment. 
  • If we follow entity mapping like JPA/Hibernate, it will cause issues. So, better avoid Blue-Green deployment in this scenario.

Summary: Follow these steps if you use application scaling

  • cf scale version_one -i 2
  • cf routes (make a note of host name)
  • cf push version_two -p version_two.jar -n versiononetemp –no-start
  • cf routes (make sure host and route generated)
  • cf map-route version_two –hostname versionone
  • cf scale version_one -i 1
  • cf scale version_two -i 2
  • cf unmap-route version_one -n versionone
  • cf unmap-route version_two -n versiononetemp
Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s