Configure Blue-Green Deployment
Blue-green deployment is a strategy that minimizes downtime and risk by using two identical environments: Blue (current live) and Green (new version). Traffic is switched from Blue to Green once the new version is verified, allowing seamless updates. If issues occur, you can quickly revert to Blue, ensuring continuous service with minimal disruption.
Below is an interactive demo that provides a hands-on introduction to blue-green deployment using API7 Enterprise.
Configure Blue/Green Upstreams
- Select Published Services of your gateway group from the side navigation bar, then click the service you want to modify, for example,
httpbin
. - Under the published service, select Upstreams from the side navigation bar.
- In the Default Upstream module, click Edit, rename the upstream to
Blue Upstream
, and click Save. - In the Canary Rules module, click Start Canary.
- In the dialog box, do the following:
- In the Weight field, enter
100
. - In the Condition field, keep the button off.
- Click Next.
- In the Weight field, enter
- In the Canary Upstream field, choose Create a new upstream.
- In the Upstream Name field, enter
Green Upstream
. - Click Edit to adjust the host of the node to point to the new backend. For example, use
172.16.1.82
as the host and80
as the port. - Click Save.
- In the Upstream Name field, enter
- Click Start. The canary rules start working immediately.
Validate
Validate the Green Upstream by sending a request:
curl "http://127.0.0.1:9080/headers" -v
You will receive a 200 OK
response with the header green
.
Finish Canary Rules
- In the Canary Rules field, click Actions and Finish.
- In the dialog box, do the following:
- In the Baseline Upstream field, choose
Canary Upstream: Green Upstream
. - In the Delete Unselected Upstream: Default Upstream field, turn off the button.
- Click Finish. The Blue Upstream is a history upstream that you can send traffic to when necessary.
- In the Baseline Upstream field, choose