Lesson 2: Preparing the application#

Prepare the application environments for the blue-green deployment.

Before you begin the lesson, make sure that you completed the Prerequisites.

In this lesson, you modify the JPetStore application by adding the resources that you created in the previous lesson. To complete the lesson, you define environments and create properties that are used by the process that you create in the next lesson.

If you use another application other than JPetStore, you can still apply the steps described in this lesson.

Parent topic: Blue-green deployments

Creating the environments#

Prepare the blue-green environments.

  1. For the JPetStore application, create an application property and name it activeEnvironment, and assign it a value of Blue environment.

    The application process checks the value of this property to ensure that the active environment is not updated. At the start of the tutorial, the Blue environment is the active environment.

  2. Create an environment, named Blue environment, to use for the Blue system.

  3. Create an environment property for the Blue environment and name it LBPort. Assign a value of 8081 to the property.

    When you create component processes, you often define parameters that specify the location of artifacts on the target system, such as the location of the application server. Because these properties can vary on different target systems, you specify these properties as environment properties. Because you're using ports to distinguish the Blue and Green environments, you add a property to each environment named LBPort. This property stores the port that the application is running on in each environment; in this case, 8081 for Blue and 8082 for Green.

    Note: For the tutorial, you can use any environment property. The tutorial abstractly references ports because, as an exercise, you might use a proxy server to simulate a load balancer. Switching ports with a proxy server, such as HAProxy, is an easy way to test blue-green deployments without using an actual load balancer and separate nodes.

  4. Add the JPetStore environment properties to the environment.

    The JPetStore application uses several environment property to deploy its web application. If you are using your own application, you can skip this step.

  5. Add theBlue system agent resource to the Blue environment.

    Because you put the JPetStore component tag on the resource, you don't have to map the individual components. The component tag grabs all of the components at once.

    The resource is shown on the Resources tab for the environment, as shown in the following figure:

    The Resources tab for the environment, which shows the resource that is bound to the environment

  6. Add the load balancer agent resource to the environment.

    Later, you call processes to update the load balancer as part of the regular deployment processes.

  7. Create the Green environment similar to the Blue environment, and assign the Green system agent resource to it. Create theLBPort environment property for the Green environment, and assign the value 8082 to it.

The new environments appear on the Environments tab.