Today we’re going to demonstrate how to deploy the on-premises version of OpenResty XRay on Microsoft’s Azure cloud. For a detailed description of the commands used in this video, see the documentation.

Create a subscription and a resource group

The first step is to create a subscription and a resource group. Open the home page of Azure. Click on the subscription icon.

Screenshot

Here we’ve created a subscription previously. It’s called Azure subscription 1.

Screenshot

Go back to the Azure home page.

Screenshot

We are going to create a resource group. Click on the resource groups icon.

Screenshot

The resource group named AKS has been created successfully. AKS is a resource group of the subscription Azure subscription 1 that we just created.

Screenshot

Create the Azure Kubernetes service

The second step is to create the Azure Kubernetes service. We go back to the Azure home page and click on the Kubernetes services icon.

Screenshot

Click the “Create” button and select “Create Kubernetes cluster”

Screenshot

Select the resource group that we just created, named AKS.

Screenshot

Here we choose the preset configuration of the cluster according to our needs.

Screenshot

Here we can select the size of the node.

Screenshot

We can modify the configuration as needed, and then click on Review + Create.

Screenshot

Screenshot

Wait until the deployment is complete.

Screenshot

Screenshot

Prepare the environment variables

Step 3: Prepare the environment variables to be used later.

Open a terminal and log in to the Linux machine.

Let’s use the .env.sample file to do the demonstration.

Screenshot

The instructions for using these environment variables are described in the documentation.

Screenshot

Log in to Azure from the command line

Step 4: log in to Azure from the command line.

Please note that we need to have Azure’s command line tool az to be installed in advance.

Refer to the official Azure documentation for the installation details.

We use the command az login to open the URL on the prompt.

Screenshot

After successful login, the screen should display as follows.

Screenshot

Execute the command az account to bind the subscription.

Screenshot

Screenshot

Next, execute the az aks command to get the Kubernetes access configuration.

Screenshot

Create the namespace and secret for Kubernetes

Step 5: create the namespace and secret for Kubernetes.

First, create the Kubernetes namespace.

Screenshot

And then create the Kubernetes secret.

Screenshot

Create the Azure Disk

Step 6: Create the Azure Disk.

First, get the resource group name of the node.

Screenshot

Then use the command to create an Azure disk.

Screenshot

Use the same commands to create multiple disks to be used. These commands are described in our documentation.

Screenshot

Update the configuration file for the persistent volume

Step 7: update the configuration file for the persistent volume.

Use the configuration file we provide in this step.

Screenshot

Get the resource group name of the node.

Screenshot

Replace the configuration of the persistent volume using the command sed.

Screenshot

Update the Kubernetes configuration file

Step 8: update the Kubernetes configuration file.

Screenshot

The variable XRAY_CONSOLE_HOST is the domain name to use once the OpenResty XRay service is deployed.

Screenshot

Replace the Kubernetes configuration using the sed command.

Screenshot

Create the persistent volume

Step 9: Create the persistent volume.

Just use the kubectl apply command.

Screenshot

Once the persistent volume has been successfully created, we can check it using the kubectl get command.

Screenshot

Deploy the Kubernetes service

Step 10: Deploy the Kubernetes service.

Here we use the command kubectl apply to deploy the Kubernetes service.

Screenshot

Check the service status using the kubectl get command. Running means that the deployment was successful.

Screenshot

Configure the application gateway

The last step is to configure the application gateway.

Open the Azure home page. Open the Kubernetes service.

Screenshot

Screenshot

Choose Networking to configure the network.

Screenshot

Check “Enable ingress controller”.

Screenshot

Save.

Screenshot

An ingress controller will be created clicking on apply.

Screenshot

Select the ingress controller just created and choose the Backend pool configuration.

Screenshot

Edit the existing backend pool.

Screenshot

The IP address of the backend can be obtained using the command shown in the documentation.

Screenshot

Screenshot

Save.

Screenshot

Next, configure Health Probes. This step is to configure the health check to the backend.

Screenshot

Fill in the form as shown on the screen and save it.

Screenshot

Screenshot

Screenshot

Next, we start configuring the Listeners. That is, configure the gateway’s listening ports and services.

Screenshot

We see that the http service listening on port 80 is already configured by default.

Screenshot

Let’s add an https service listening on port 443.

Screenshot

Screenshot

Here we need to upload the required certificate for the https service.

Screenshot

Screenshot

Follow the command described in the documentation to convert the normal certificate to the pfx format.

Screenshot

Enter the password of the certificate in pfx format in the Password field.

Screenshot

We select Rules to configure the forwarding rules.

Screenshot

Modify the default rules.

Screenshot

Change the Listener to the https service we just created which listens on port 443.

Screenshot

Select the tab Backend targets and make sure that the Backend targets and Backend settings are configured correctly.

Screenshot

Click save.

Screenshot

Select Health Probe to see if the health check has been passed.

Screenshot

Screenshot

The Status is passed.

Screenshot

Make sure that the domain name being accessed has been resolved to the public IP address of the gateway.

Screenshot

Now let’s access the domain name to check if the OpenResty XRay service has been deployed successfully.

When we see the following login screen it means that the deployment has been successful.

Screenshot

If you like this tutorial, please subscribe to this blog site and/or our YouTube channel. Thank you!

About The Author

Yichun Zhang (Github handle: agentzh), is the original creator of the OpenResty® open-source project and the CEO of OpenResty Inc..

Yichun is one of the earliest advocates and leaders of “open-source technology”. He worked at many internationally renowned tech companies, such as Cloudflare, Yahoo!. He is a pioneer of “edge computing”, “dynamic tracing” and “machine coding”, with over 22 years of programming and 16 years of open source experience. Yichun is well-known in the open-source space as the project leader of OpenResty®, adopted by more than 40 million global website domains.

OpenResty Inc., the enterprise software start-up founded by Yichun in 2017, has customers from some of the biggest companies in the world. Its flagship product, OpenResty XRay, is a non-invasive profiling and troubleshooting tool that significantly enhances and utilizes dynamic tracing technology. And its OpenResty Edge product is a powerful distributed traffic management and private CDN software product.

As an avid open-source contributor, Yichun has contributed more than a million lines of code to numerous open-source projects, including Linux kernel, Nginx, LuaJIT, GDB, SystemTap, LLVM, Perl, etc. He has also authored more than 60 open-source software libraries.