Skip to content

Commit 8605662

Browse files
committed
Added update from PM
1 parent 6190ee6 commit 8605662

File tree

1 file changed

+71
-22
lines changed

1 file changed

+71
-22
lines changed

articles/azure-cache-for-redis/cache-tutorial-active-replication.md

Lines changed: 71 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ In this tutorial, you will host a simple inventory application on Azure Kubernet
1919

2020
- An Azure subscription. If you don't have an Azure subscription, create a [free account](https://azure.microsoft.com/free/?WT.mc_id=A261C142F).
2121
- 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.
2224

2325
> [!IMPORTANT]
2426
> This tutorial assumes that you are familiar with basic Kubernetes concepts like containers, pods and service.
@@ -52,6 +54,8 @@ To demonstrate data replication across regions, we run two instances of the same
5254

5355
1. Update environment variables `REDIS_HOST` and `REDIS_PASSWORD` with _hostname_ and _access key_ of your _West US 2_ cache.
5456
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.
5559

5660
```YAML
5761
apiVersion: apps/v1
@@ -81,7 +85,7 @@ To demonstrate data replication across regions, we run two instances of the same
8185
memory: "128Mi"
8286
env:
8387
- name: REDIS_HOST
84-
value: "DemoWest.westus.redisenterprise.cache.azure.net"
88+
value: "DemoWest.westus2.redisenterprise.cache.azure.net"
8589
- name: REDIS_PASSWORD
8690
value: "myaccesskey"
8791
- name: REDIS_PORT
@@ -108,8 +112,65 @@ To demonstrate data replication across regions, we run two instances of the same
108112
109113
1. Save another copy of the same YAML file as _app_east.yaml_. This time, use different values.
110114
111-
1. Update environment variables `REDIS_HOST` and `REDIS_PASSWORD` with _hostname_ and _access key_ of your _East US_ cache.
115+
1. Update environment variables `REDIS_HOST` and `REDIS_PASSWORD` with Eendpoint_ and _access key_ of your _East US_ cache.
112116
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.
119+
120+
It should look like below:
121+
122+
```YAML
123+
apiVersion: apps/v1
124+
kind: Deployment
125+
metadata:
126+
name: shoppingcart-app
127+
namespace: east
128+
spec:
129+
replicas: 1
130+
selector:
131+
matchLabels:
132+
app: shoppingcart
133+
template:
134+
metadata:
135+
labels:
136+
app: shoppingcart
137+
spec:
138+
containers:
139+
- name: demoapp
140+
image: mcr.microsoft.com/azure-redis-cache/redisactivereplicationdemo:latest
141+
resources:
142+
limits:
143+
cpu: "0.5"
144+
memory: "250Mi"
145+
requests:
146+
cpu: "0.5"
147+
memory: "128Mi"
148+
env:
149+
- name: REDIS_HOST
150+
value: "DemoEast.eastus.redisenterprise.cache.azure.net"
151+
- name: REDIS_PASSWORD
152+
value: "myaccesskey"
153+
- name: REDIS_PORT
154+
value: "10000" # redis enterprise port
155+
- name: HTTP_PORT
156+
value: "8080"
157+
- name: APP_LOCATION
158+
value: "New York, NY"
159+
---
160+
apiVersion: v1
161+
kind: Service
162+
metadata:
163+
name: shoppingcart-svc
164+
namespace: east
165+
spec:
166+
type: LoadBalancer
167+
ports:
168+
- protocol: TCP
169+
port: 80
170+
targetPort: 8080
171+
selector:
172+
app: shoppingcart
173+
```
113174

114175
## Install and connect to your AKS cluster
115176

@@ -130,13 +191,12 @@ If you use Azure Cloud Shell, _kubectl_ is already installed, and you can skip t
130191
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:
131192

132193
```bash
133-
az aks get-credentials --resource-group myResourceGroup --name myClusterName -f AKS_WestUS2
194+
az aks get-credentials --resource-group myResourceGroup --name myClusterName
134195
```
135196

136197
Verify that you are able to connect to your cluster by running the following command:
137198

138199
```bash
139-
set kubeconfig=AKS_WestUS2
140200
141201
kubectl get nodes
142202
```
@@ -150,26 +210,15 @@ aks-agentpool-21274953-vmss000003 Ready agent 1d v1.24.15
150210
aks-agentpool-21274953-vmss000006 Ready agent 1d v1.24.15
151211
```
152212

153-
Now, repeat the steps for getting credentials for your AKS cluster in East US region.
154-
155-
```bash
156-
az aks get-credentials --resource-group myResourceGroup --name myClusterName -f AKS_EastUS
157-
158-
set kubeconfig=AKS_EastUS
159-
160-
kubectl get nodes
161-
```
162-
163-
Thus, you now have context on your machine to connect to both the AKS clusters on your machine.
164-
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.
165-
166213

167214
## Deploy and test your application
168215

169-
Run the following command to deploy the application instance to your AKS cluster in **West US 2**:
216+
You need two namespaces for your applications to run on your AKS cluster. Create a west and then deploy the application.
217+
218+
Run the following command to deploy the application instance to your AKS cluster in the _west_ namespace:
170219

171220
```bash
172-
set kubeconfig=AKS_WestUS2
221+
kubectl create namespace west
173222
174223
kubectl apply -f app_west.yaml
175224
```
@@ -209,14 +258,14 @@ shoppingcart-svc LoadBalancer 10.0.166.147 20.69.136.105 80:30390/TC
209258

210259
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:
211260

212-
<!-- <screenshot for Seattle> -->
261+
<!-- screenshot for Seattle -->
213262

214263
Run the same deployment steps and deploy an instance of the demo application to run in East US region.
215264

216265
```bash
217-
set kubeconfig=AKS_EastUS
266+
kubectl create namespace east
218267
219-
kubectl apply -f app_east
268+
kubectl apply -f app_east.yml
220269
221270
kubectl get pods -n east
222271

0 commit comments

Comments
 (0)