Blue-green release is a zero downtime application update policy. During a blue-green release, the old and new service versions of an application coexist, and also share routes. By adjusting the route weights, you can switch traffic between different service versions. After the new version passes the verification, you can delete the old service version by confirming the release. If the new version does not pass the verification, the release is rolled back and the new version is deleted.
The routing service must be upgraded to the latest version. For more information, see Upgrade system services.
In the following example, assume that you want to perform a blue-green release for an Nginx static page application. The initial application template is as follows:
After the deployment, the page is as follows.
Log on to the Container Service console.
Click Applications in the left-side navigation pane.
Select the cluster in which the application resides from the Cluster list.
Click Update at the right of the application.
Set the release mode and the configurations of the new service version.
- The new and old versions cannot share the same name.
- To make sure that the application does not experience downtime when switching versions, the weight of the new service version is set to 0 by default. On the route management page, you must adjust the weight to switch traffic to the new version.
The template sample is as follows:
Click OK to release the changed version.
The release process goes through two statuses:
- Blue-green release in progress: Indicates that the startup of the new service version is not completed.
Blue-green release awaiting confirmation: Indicates that the startup of the new service version is completed. Another release can be performed until this release is confirmed or rolled back.
Click the application name to go to the application details page. You can see that the new and old application versions coexist.
Click the Routes tab and then click Set service weight.
The old version has a weight of 100 and the new version has a weight of 0.
To realize zero downtime update, set the weight of the new version to 100. Now the new version and old version account for 50% of the weight respectively. Test if both versions have stable traffic.
Note: Adjusting the weights of the new version and old version at the same time might result in the failure of some requests. Therefore, adjust the weights in two steps and only adjust the weight of one version in each step. For example, adjust the weight of the new version from 0 to 100 first, and then adjust the weight of the old version from 100 to 0 after the traffic is stable.
Then, adjust the weight of the old version to 0 and that of the new version to 100.
The routing service enables the session persistence by default. Therefore, you can open a new browser window to access the new version.
After the entire release process has been verified, click Confirm Release Completion on the Application List page. Select whether or not to automatically perform the smooth update in the displayed dialog box and click OK to confirm the release before you can release subsequent versions.
Now the service list of the application has been updated and the old service version has been taken offline and deleted.