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
+67-25Lines changed: 67 additions & 25 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -22,7 +22,7 @@ This tutorial uses a sample inventory page which shows three different T-shirt o
22
22
## Prerequisites
23
23
24
24
- An Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
25
-
-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). Alternately, you can host two instances of the demo application on the same AKS cluster.
25
+
-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.
26
26
27
27
> [!IMPORTANT]
28
28
> This tutorial assumes that you are familiar with basic Kubernetes concepts like containers, pods and service.
@@ -45,7 +45,7 @@ This tutorial uses a sample inventory page which shows three different T-shirt o
45
45
To demonstrate data replication across regions, we will run two instances of the same application in different regions. Let's assume one instance runs in Seattle (west) while the second in New York(east).
46
46
47
47
Update the following fields in the YAML file below and save it as app_west.yaml
48
-
* Update environment variables REDIS_HOST and REDIS_PASSWORD with hostname and access key of your Azure Cache for Redis Enterprise instance in West US 2 or one of the two regions your chose earlier.
48
+
* 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.
49
49
* Update APP_LOCATION to display the region where this application instance is running. In this sample, we are configuring the APP_LOCATION to Seattle to indicate this application instance is running in Seattle.
Save another copy of the same YAML file as app_east.yaml. This time, update the REDIS_HOST, REDIS_PASSWORD and APP_LOCATION to point to Redis Enterprise instance in East US or your second region of choice.
104
+
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.
@@ -119,14 +174,12 @@ If you use Azure Cloud Shell, _kubectl_ is already installed, and you can skip t
119
174
Use the portal to copy the resource group and cluster name for your AKS cluster in the West US 2 region. To configure _kubectl_ to connect to your AKS cluster, use the following command with your resource group and cluster name:
120
175
121
176
```bash
122
-
az aks get-credentials --resource-group myResourceGroup --name myClusterName -f AKS_WestUS2
177
+
az aks get-credentials --resource-group myResourceGroup --name myClusterName
123
178
```
124
179
125
180
Verify that you are able to connect to your cluster by running the following command:
Now, repeat the steps for getting credentials for your AKS cluster in East US region.
143
-
144
-
```bash
145
-
az aks get-credentials --resource-group myResourceGroup --name myClusterName -f AKS_EastUS
146
-
147
-
set kubeconfig=AKS_EastUS
148
-
149
-
kubectl get nodes
150
-
```
151
-
152
-
Thus, you now have context on your machine to connect to both the AKS clusters on your machine.
194
+
153
195
Alternately, you can apply the YAML files to appropriate AKS clusters through portal directly. To apply YAML through portal, go to the "Services and ingresses" blade for your AKS cluster, and click on the "Create" and choose "Apply a YAML" option. This will open an editor where you can copy paste your YAML file.
154
196
155
197
@@ -158,7 +200,7 @@ Alternately, you can apply the YAML files to appropriate AKS clusters through po
158
200
Run the following command to deploy the application instance to your AKS cluster in **West US 2**:
159
201
160
202
```bash
161
-
set kubeconfig=AKS_WestUS2
203
+
kubectl create namespace west
162
204
163
205
kubectl apply -f app_west.yaml
164
206
```
@@ -201,14 +243,15 @@ Once the External-IP is available, open a web browser to the External-IP address
201
243
Run the same deployment steps and deploy an instance of the demo application to run in East US region.
202
244
203
245
```bash
204
-
set kubeconfig=AKS_EastUS
246
+
kubectl create namespace east
205
247
206
-
kubectl apply -f app_east
248
+
kubectl apply -f app_east.yaml
207
249
208
250
kubectl get pods -n east
209
251
210
252
kubectl get service -n east
211
253
```
254
+
212
255
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.
213
256
214
257
You did it! Click on the buttons and explore the demo. To reset the count, add "/reset" after the url. e.g. <IPaddress>/reset
@@ -219,15 +262,14 @@ You did it! Click on the buttons and explore the demo. To reset the count, add "
219
262
To clean up your cluster, run the following commands:
220
263
221
264
```bash
222
-
set kubeconfig=AKS_WestUS2
223
265
kubectl delete deployment shoppingcart-app -n west
224
266
kubectl delete service shoppingcart-svc -n west
225
-
226
-
set kubeconfig=AKS_EastUS
227
267
kubectl delete deployment shoppingcart-app -n east
228
268
kubectl delete service shoppingcart-svc -n east
229
269
```
230
270
271
+
Proceed with deleting your AKS cluster, your Azure Cache for Redis Enterprise instances and the resource group.
0 commit comments