Assistant Engineer
Assistant Engineer
  • UID621
  • Fans1
  • Follows0
  • Posts55

DevOps and Alibaba Cloud Docker (III)

More Posted time:Dec 28, 2016 14:58 PM
If you ask ten philosophers what “philosophy” is, you will typically get 11 answers (one of them being your’s.
Only one philosophical question is serious, that is, life and death.
For DevOps, there are three serious questions.
1. How to recreate your system?
2. How to safely deploy your system?
3. Monitoring of and solutions to problems after system deployment.
Today, we will talk about how to deploy your system safely. The term deployment involves a lot of meaning. The simplest explanation is how to make your application run in the final environment. But there are a lot of best practices for deployment.
Next, we will discuss a few common releasing methods, and the combined usage of these releasing methods and containers.
Release strategy
Common release strategies include blue-green release, canary release (grey release) and ABTest.
Blue-green release
Blue-green release is usually called hot deployment. During the release process, users won’t perceive service restarts, which is usually achieved through the coexistence of old and new versions. That is to say, during the releasing process, the new version and the old version act as the hot standby of each other and by switching the routing weight (either 0 or 100), the launching or removal of different applications is achieved.
Canary release
By adding a small number of new-version services in the running services online, and then getting quick feedback from the few new-version services, the final form of delivery can be determined based on the feedback.
Gray release
Gray release is the process of switching routing weights between coexisting versions online to achieve the switch from one version to another. Although British software developer Martin Fowler believes that the gray release and canary release are the same, the two do vary in specific operations and purposes. Canary release focuses more on getting fast feedback, and gray release focuses more on the smooth switch from one version to another.


ABTest and gray release have much in common, but you can distinguish the two from their releasing purposes. The former focuses on the difference from Version A or Version B, and makes decisions based on the difference to select one version for deployment. So compared with gray release, ABTest is more inclined to decision-making, and compared with canary release, ABTest is more flexible in weights and traffic flow switching.
Implement blue-green release using Alibaba Cloud Docker
Next, we will demonstrate the process of a blue-green release with a simple example. Suppose the application for blue-green release is a static page on nginx. The initial application template is as follows:
 image: ''
   aliyun.routing.port_80: nginx
 restart: always
The page after deployment is shown as follows:
l  Click to change configuration
l  Select the changed release strategy and configuration for the new-version service
 image: ''
   aliyun.routing.coexist: true
   aliyun.routing.port_80: nginx
 restart: always
l  In the blue-green release, the new and the old versions cannot share the name. If they share one routing address, you need to add a label of aliyun.routing.coexist, which means that the current service shares the routing address with other services. In the blue-green release scenario, to ensure zero-downtime switch of the application, the routing weight of the new-version service is by default 0, and needs to be adjusted on the routing management page before traffic switching. The release process involves two states: the blue-green release in process, and the blue-green release to be confirmed.
l  The blue-green release in process state indicates that the new-version service has not been started yet, and the blue-green release to be confirmed state indicates that the new-version service has been started. At this time, you need to confirm the release or release rollback to proceed to the next release. Go to the application details page, you can see the coexisting new-version application and the old-version application.
To be specific, the blue service is the old-version service, and the green service is the new-version service. If a service exists in both versions and there is no change, there will be a yellow label, indicating the application won’t have any changes in the blue-green release.
l  Click the router list and adjust the corresponding routing weight.
l  As shown in the figure: the weight of the old-version service is 100 and that of the new-version service is 0. Next we will adjust the weight of the old-version service to 0 and the weight of the new-version service to 100.
l  Since the default routing service is session persistence enabled, you can open a new browser window to access the new version, and the results are as follows.
l  After the entire release process is validated, you need to confirm the release before proceeding to the next release.
l  After you confirm the release, you can view the application details and you will find that the service list of the application has been updated, and old services have been fully removed.