You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: articles/azure-cache-for-redis/cache-tutorial-active-replication.md
+29-25Lines changed: 29 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,31 @@
1
1
---
2
2
title: 'Tutorial: Get started using Azure Cache for Redis Enterprise active replication with an AKS-hosted application'
3
-
description: In this tutorial, you learn how to connect your AKS hosted application to Azure Cache for Redis Enterprise instances and leverage active geo-replication.
3
+
description: In this tutorial, you learn how to connect your AKS hosted application to a cache that uses active geo-replication.
4
4
author: flang-msft
5
5
6
6
ms.author: franlanglois
7
7
ms.service: cache
8
8
ms.topic: tutorial
9
9
ms.date: 09/18/2023
10
-
#CustomerIntent: As a developer, I want to see how to use a Azure Cache for Redis Enterprise instance with an AKS container so that I see how I can use my cache instance with a Kubernetes cluster.
10
+
#CustomerIntent: As a developer, I want to see how to use a Enterprise cache that uses active geo-replication to capture data from two apps running against different caches in separate geo-locations.
11
11
12
12
---
13
13
14
14
# Get started using Azure Cache for Redis Enterprise active replication with an AKS-hosted application
15
15
16
-
In this tutorial, you will host a simple inventory application on Azure Kubernetes Service (AKS) and find out how you can use active geo-replication to replicate data in your Azure Cache for Redis Enterprise instances across Azure regions.
16
+
In this tutorial, you will host an inventory application on Azure Kubernetes Service (AKS) and find out how you can use active geo-replication to replicate data in your Azure Cache for Redis Enterprise instances across Azure regions.
17
17
18
18
## Prerequisites
19
19
20
20
- An Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
21
-
- Two Azure Kubernetes Service Clusters in different regions- For more information on creating a cluster, see [Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using the Azure portal](/azure/aks/learn/quick-kubernetes-deploy-portal). Alternatively, you can host two instances of the demo application on the same AKS cluster.
22
-
<!-- SP -->
23
-
- One Azure Kubernetes Service Cluster - For more information on creating a cluster, see [Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using the Azure portal](/azure/aks/learn/quick-kubernetes-deploy-portal). Alternately, you can host two instances of the demo application on the two different AKS clusters, which will how your production environment will be set up. However, for this tutorial, we will deploy both instances of the application on the same AKS cluster.
21
+
- One Azure Kubernetes Service Cluster - For more information on creating a cluster, see [Quickstart: Deploy an Azure Kubernetes Service (AKS) cluster using the Azure portal](/azure/aks/learn/quick-kubernetes-deploy-portal). Alternatively, you can host two instances of the demo application on the two different AKS clusters. In a production environment, you would use two different clusters located in the same regions as your clusters to deploy two versions of the application. For this tutorial, you deploy both instances of the application on the same AKS cluster.
24
22
25
23
> [!IMPORTANT]
26
24
> This tutorial assumes that you are familiar with basic Kubernetes concepts like containers, pods and service.
27
25
28
26
## Overview
29
27
30
-
This tutorial uses a sample inventory page which shows three different T-shirt options. The user can "purchase" each T-shirt and see the inventory drop. The unique thing about this demo is that we run the inventory app in two different regions. Typically, you would have to run the database storing inventory data in a single region so that there are no consistency issues. That can result in unpleasant customer experience due to higher latency for calls across different Azure regions. By using Azure Cache for Redis Enterprise as the backend, however, you can link two caches together with active geo-replication so that the inventory remains consistent across both regions while enjoying low latency performance from Redis Enterprise in the same region.
28
+
This tutorial uses a sample inventory page that shows three different T-shirt options. The user can "purchase" each T-shirt and see the inventory drop. The unique thing about this demo is that we run the inventory app in two different regions. Typically, you would have to run the database storing inventory data in a single region so that there are no consistency issues. With other database backends and synchronization, customers might have unpleasant experience due to higher latency for calls across different Azure regions. When you use Azure Cache for Redis Enterprise as the backend, you can link two caches together with active geo-replication so that the inventory remains consistent across both regions while enjoying low latency performance from Redis Enterprise in the same region.
31
29
32
30
## Set up two Azure Cache for Redis instances
33
31
@@ -48,14 +46,18 @@ This tutorial uses a sample inventory page which shows three different T-shirt o
48
46
49
47
Create two .yml files using the following procedure. One file for each cache you created in the two regions.
50
48
51
-
To demonstrate data replication across regions, we run two instances of the same application in different regions. Let's make one instance run in Seattle (west), while the second runs in New York (east).
49
+
To demonstrate data replication across regions, we run two instances of the same application in different regions. Let's make one instance run in Seattle, west namespace, while the second runs in New York, east namespace.
52
50
53
-
1. Update the following fields in the YAML file below and save it as _app_west.yaml_.
51
+
### West namespace
54
52
55
-
1. Update environment variables `REDIS_HOST` and `REDIS_PASSWORD` with _hostname_ and _access key_ of your _West US 2_ cache.
56
-
1. Update `APP_LOCATION` to display the region where this application instance is running. For this cache, configure the `APP_LOCATION` to _Seattle_ to indicate this application instance is running in Seattle.
57
-
<!-- sp -->
58
-
1. Update environment variables REDIS_HOST and REDIS_PASSWORD with endpoint (remove the suffix ":10000") and access key of your Azure Cache for Redis Enterprise instance in West US 2 or one of the two regions your chose earlier.
53
+
1. Update the following fields in the following YAML file and save it as _app_west.yaml_.
54
+
55
+
1. Update the variable `REDIS_HOST` with the **Endpoint value** URL after removing the port suffix: 10000
56
+
1. Update `REDIS_PASSWORD` with the **Access key** of your _West US 2_ cache.
57
+
1. Update `APP_LOCATION` to display the region where this application instance is running. For this cache, configure the `APP_LOCATION` to `Seattle` to indicate this application instance is running in Seattle.
58
+
1. Verify that the variable `namespace` value is `west` in both places in the file.
59
+
60
+
It should look like following code:
59
61
60
62
```YAML
61
63
apiVersion: apps/v1
@@ -110,14 +112,16 @@ To demonstrate data replication across regions, we run two instances of the same
110
112
app: shoppingcart
111
113
```
112
114
113
-
1. Save another copy of the same YAML file as _app_east.yaml_. This time, use different values.
115
+
### East namespace
116
+
117
+
1. Save another copy of the same YAML file as _app_east.yaml_. This time, use the values that correspond with your second cache.
114
118
115
-
1. Update environment variables `REDIS_HOST` and `REDIS_PASSWORD` with Eendpoint_ and _access key_ of your _East US_ cache.
119
+
1. Update the variable `REDIS_HOST` with the **Endpoint value** after removing the port suffix: 10000
120
+
1. Update `REDIS_PASSWORD` with the **Access key** of your _East US_ cache.
116
121
1. Update `APP_LOCATION` to display the region where this application instance is running. For this cache, configure the `APP_LOCATION` to _New York_ to indicate this application instance is running in New York.
117
-
118
-
1. +Save another copy of the same YAML file as app_east.yaml. This time, update the namespace, REDIS_HOST, REDIS_PASSWORD and APP_LOCATION to point to Redis Enterprise instance in East US or your second region of choice.
122
+
1. Verify that the variable `namespace` value is `east` in both places in the file.
119
123
120
-
It should look like below:
124
+
It should look like following code:
121
125
122
126
```YAML
123
127
apiVersion: apps/v1
@@ -176,9 +180,12 @@ spec:
176
180
177
181
In this section, you first install the Kubernetes CLI and then connect to an AKS cluster.
178
182
183
+
> [!NOTE]
184
+
> For this part of the tutorial, a Azure Kubernetes Service Cluster is required. For this tutorial, you deploy both instances of the application on the same AKS cluster.
185
+
179
186
### Install the Kubernetes CLI
180
187
181
-
Use the Kubernetes CLI, _kubectl_ , to connect to the Kubernetes cluster from your local computer. If you are running locally, then you can using the following command to install kubectl.
188
+
Use the Kubernetes CLI, _kubectl, to connect to the Kubernetes cluster from your local computer. If you're running locally, then you can use the following command to install kubectl.
182
189
183
190
```bash
184
191
az aks install-cli
@@ -194,7 +201,7 @@ Use the portal to copy the resource group and cluster name for your AKS cluster
194
201
az aks get-credentials --resource-group myResourceGroup --name myClusterName
195
202
```
196
203
197
-
Verify that you are able to connect to your cluster by running the following command:
204
+
Verify that you're able to connect to your cluster by running the following command:
Once the External-IP is available, open a web browser to the External-IP address of your service and you see the application running like below:
265
+
Once the External-IP is available, open a web browser to the External-IP address of your service and you see the application running as follows:
260
266
261
267
<!-- screenshot for Seattle -->
262
268
@@ -272,7 +278,7 @@ kubectl get pods -n east
272
278
kubectl get service -n east
273
279
```
274
280
275
-
With two services opened in your browser, you should see that changing the inventory in one region is virtually instantly reflected in the other region. The inventory data is stored in the Redis Enterprise instances which are replicating data across regions.
281
+
With two services opened in your browser, you should see that changing the inventory in one region is almost instantly reflected in the other region. The inventory data is stored in the Redis Enterprise instances that are replicating data across regions.
276
282
277
283
You did it! Click on the buttons and explore the demo. To reset the count, add `/reset` after the url:
278
284
@@ -283,11 +289,9 @@ You did it! Click on the buttons and explore the demo. To reset the count, add `
283
289
To clean up your cluster, run the following commands:
284
290
285
291
```bash
286
-
set kubeconfig=AKS_WestUS2
287
292
kubectl delete deployment shoppingcart-app -n west
288
293
kubectl delete service shoppingcart-svc -n west
289
294
290
-
set kubeconfig=AKS_EastUS
291
295
kubectl delete deployment shoppingcart-app -n east
0 commit comments