In this tutorial, you will learn how to use OpenResty Edge Test your gateway configuration changes and push them to the gateway servers in all production environments.

What is a grayscale server

As we know, Edge Admin is responsible for managing and distributing configuration to Edge servers. But distributing major changes directly to all Edge servers may lead to accidents.

 Embeded video

To solve this problem, we can mark some Edge servers as grayscale servers. First publish the changes to these grayscale servers, and then publish them to all servers after testing. This is our topic today: grayscale server.

 Embeded image

Let's go OpenResty Edge Admin Web Console for. This is a sample deployment of our console. Each user has its own local deployment.

Screenshot

Set gateway server as grayscale server

First, let's see how to set the gateway server as a grayscale server.

Click the Gateway Clusters tab to enter the Gateway Clusters page.

Screenshot

We have a gateway cluster with two gateway servers.

Screenshot

Now we will set these two gateway servers as grayscale servers. This can be achieved in two ways. The first is to set the entire gateway cluster as a grayscale cluster. Now let's see how to set it up.

Click to edit the cluster.

Screenshot

There is a switch to set whether a cluster is a grayscale cluster.

Screenshot

The switch is now off.

To set this gateway cluster as a grayscale cluster, you need to turn on this switch.

Screenshot

Click to save this change.

Screenshot

Click the cluster name to enter the server list page.

Screenshot

As you can see from the server list page, these two servers have now been identified as grayscale servers.

Screenshot

Return to the gateway cluster page.

Screenshot

The second method is to directly set a gateway server as a grayscale server.

Click the Edit button again.

Screenshot

Turn off this switch.

Screenshot

You can see that there is a switch under each server to set whether the server is a grayscale server.

Screenshot

Turn on this switch.

Screenshot

Click to save this change.

Screenshot

Click the cluster name.

Screenshot

As you can see, the first server is still a grayscale server.

Screenshot

The second server is no longer a grayscale server.

Screenshot

This is just for the convenience of demonstration. In fact, we do not recommend that a cluster have both grayscale servers and non grayscale servers. Otherwise, the distribution of configuration on the cluster level will cause problems.

Publish changes to grayscale server

Now let's go back to the application list page and see how to publish the changes to the grayscale server.

Screenshot

We can continue to use the previous example application, test-edge.com.

Screenshot

Enter this application.

Screenshot

Create a new page rule to test grayscale publishing.

Screenshot

Click New Page Rule. This rule will return specific content under a specific URI.

Screenshot

First, we add a condition to this rule.

Screenshot

The variable of the condition remains unchanged, that is, the URI.

Screenshot

Select the String=operator.

Screenshot

Screenshot

Input value /test As the specified URI.

Screenshot

Condition setting is completed.

For the action part of the rule, we can configure an Output response body action. Please note that we chose this action only for the convenience of demonstration. The grayscale server is valid for any configuration.

Screenshot

There are many actions to choose from.

Screenshot

Suggested input Output Search.

Screenshot

Select the action "Output response body".

Screenshot

Select text/plain as the content type.

Screenshot

Screenshot

Enter "Hello World" as the output response body.

Screenshot

Click this option to ensure that the rule is inserted before the existing rule.

Screenshot

Click Create to create this rule.

Screenshot

You can see that this rule has already appeared in the list.

Screenshot

The last step is to publish a new configuration. It will push our changes to the gateway server.

Screenshot

Click this button to make a new release.

Screenshot

Add a comment to this post.

Screenshot

To make a grayscale release, you need to turn on this switch.

Screenshot

All grayscale servers are displayed here.

Screenshot

release.

Screenshot

It is now fully synchronized.

Screenshot

We can still see the changes we just made in the list of unpublished changes. This is because changes are not published to all Edge nodes, but only to grayscale nodes.

Screenshot

The changes we just made can be seen in the list of release history.

Screenshot

As you can see, the publishing type is grayscale publishing.

Screenshot

Test changes on grayscale servers

Now let's enter the gateway cluster list and select the server for testing.

Screenshot

Note that the server whose IP address ends with 226 is a grayscale server. Click to copy this address.

Screenshot

Use this grayscale server

Screenshot

To send the request.

Screenshot

To make the output look clearer, we add a carriage return here.

Screenshot

You can see that Hello World is returned.

Screenshot

Now let's test it with a non grayscale server. Click to copy the server whose IP address ends with 213.

Screenshot

Use this non grayscale server.

Screenshot

You can see that 404 is returned. This means that the changes we just made do not take effect on this server.

Screenshot

About OpenResty Edge

OpenResty Edge It is a fully functional gateway software that we independently developed and is most suitable for microservices and distributed traffic. It provides various functions such as page rules, Web Application Firewall (WAF), load balancing, etc.

If you like this tutorial, please subscribe to this blog site and our YouTube Channel or Station B channel thank you!

About the author

Zhang Yichun is open source OpenResty ® Project founder and OpenResty Inc. CEO and founder of the company.

Zhang Yichun (Github ID: agentzh) was born in Jiangsu, China, and now lives in the U.S. Bay Area. He was an advocate and leader of China's early open source technology and culture, and once worked for many internationally renowned high-tech enterprises, such as Cloudflare Yahoo, Alibaba, the pioneer of "edge computing", "dynamic tracking" and "machine programming", has more than 22 years of programming and 16 years of open source experience. As the leader of open source projects with more than 40 million global domain name users, he OpenResty ® High tech enterprises created by open source projects OpenResty Inc. It is located in the center of Silicon Valley in the United States. Its two main products OpenResty XRay (Utilize Dynamic tracking Technology) and OpenResty Edge (The all-purpose gateway software most suitable for microservices and distributed traffic), widely favored by many listed and large enterprises worldwide. Besides OpenResty, Zhang Yichun has contributed more than one million lines of code to many open source projects, including Linux kernel, Nginx LuaJIT GDB SystemTap LLVM , Perl, etc., and has written more than 60 open source software libraries.

Follow us

If you like this article, please follow us OpenResty Inc. Corporate Blog Site You are also welcome to scan our WeChat official account:

Our

translate

We provide English version Original text and Chinese translation (this article). We also welcome readers to provide translations in other languages. As long as the full text translation is not omitted, we will consider using it. Thank you very much!