Lesson 2: Preparing the application
Prepare the application environments for the blue-green deployment.
Before you begin
About this task
If you use another application other than JPetStore, you can still apply the steps described in this lesson.
Creating the environments
Prepare the blue-green environments.
Procedure
-
For the JPetStore application, create an application property and name it
activeEnvironment
, and assign it a value ofBlue 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. - Create an environment, named Blue environment, to use for the Blue system.
-
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.
-
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.
-
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:
-
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.
-
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.