Skip to content

Commit f8e74b0

Browse files
committed
Update tutorial to run with a single AKS cluster
1 parent 2c09d59 commit f8e74b0

File tree

1 file changed

+67
-25
lines changed

1 file changed

+67
-25
lines changed

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

Lines changed: 67 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ This tutorial uses a sample inventory page which shows three different T-shirt o
2222
## Prerequisites
2323

2424
- 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.
2626

2727
> [!IMPORTANT]
2828
> 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
4545
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).
4646

4747
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.
4949
* 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.
5050

5151
```YAML
@@ -76,7 +76,7 @@ spec:
7676
memory: "128Mi"
7777
env:
7878
- name: REDIS_HOST
79-
value: "DemoWest.westus.redisenterprise.cache.azure.net"
79+
value: "DemoWest.westus2.redisenterprise.cache.azure.net"
8080
- name: REDIS_PASSWORD
8181
value: "myaccesskey"
8282
- name: REDIS_PORT
@@ -101,7 +101,62 @@ spec:
101101
app: shoppingcart
102102
```
103103
104-
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.
105+
106+
It should look like below:
107+
108+
```YAML
109+
apiVersion: apps/v1
110+
kind: Deployment
111+
metadata:
112+
name: shoppingcart-app
113+
namespace: east
114+
spec:
115+
replicas: 1
116+
selector:
117+
matchLabels:
118+
app: shoppingcart
119+
template:
120+
metadata:
121+
labels:
122+
app: shoppingcart
123+
spec:
124+
containers:
125+
- name: demoapp
126+
image: mcr.microsoft.com/azure-redis-cache/redisactivereplicationdemo:latest
127+
resources:
128+
limits:
129+
cpu: "0.5"
130+
memory: "250Mi"
131+
requests:
132+
cpu: "0.5"
133+
memory: "128Mi"
134+
env:
135+
- name: REDIS_HOST
136+
value: "DemoEast.eastus.redisenterprise.cache.azure.net"
137+
- name: REDIS_PASSWORD
138+
value: "myaccesskey"
139+
- name: REDIS_PORT
140+
value: "10000" # redis enterprise port
141+
- name: HTTP_PORT
142+
value: "8080"
143+
- name: APP_LOCATION
144+
value: "New York, NY"
145+
---
146+
apiVersion: v1
147+
kind: Service
148+
metadata:
149+
name: shoppingcart-svc
150+
namespace: east
151+
spec:
152+
type: LoadBalancer
153+
ports:
154+
- protocol: TCP
155+
port: 80
156+
targetPort: 8080
157+
selector:
158+
app: shoppingcart
159+
```
105160
106161
## Connect to your AKS cluster
107162
@@ -119,14 +174,12 @@ If you use Azure Cloud Shell, _kubectl_ is already installed, and you can skip t
119174
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:
120175

121176
```bash
122-
az aks get-credentials --resource-group myResourceGroup --name myClusterName -f AKS_WestUS2
177+
az aks get-credentials --resource-group myResourceGroup --name myClusterName
123178
```
124179

125180
Verify that you are able to connect to your cluster by running the following command:
126181

127182
```bash
128-
set kubeconfig=AKS_WestUS2
129-
130183
kubectl get nodes
131184
```
132185

@@ -138,18 +191,7 @@ aks-agentpool-21274953-vmss000001 Ready agent 1d v1.24.15
138191
aks-agentpool-21274953-vmss000003 Ready agent 1d v1.24.15
139192
aks-agentpool-21274953-vmss000006 Ready agent 1d v1.24.15
140193
```
141-
142-
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+
153195
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.
154196

155197

@@ -158,7 +200,7 @@ Alternately, you can apply the YAML files to appropriate AKS clusters through po
158200
Run the following command to deploy the application instance to your AKS cluster in **West US 2**:
159201

160202
```bash
161-
set kubeconfig=AKS_WestUS2
203+
kubectl create namespace west
162204

163205
kubectl apply -f app_west.yaml
164206
```
@@ -201,14 +243,15 @@ Once the External-IP is available, open a web browser to the External-IP address
201243
Run the same deployment steps and deploy an instance of the demo application to run in East US region.
202244

203245
```bash
204-
set kubeconfig=AKS_EastUS
246+
kubectl create namespace east
205247

206-
kubectl apply -f app_east
248+
kubectl apply -f app_east.yaml
207249

208250
kubectl get pods -n east
209251

210252
kubectl get service -n east
211253
```
254+
212255
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.
213256

214257
You did it! Click on the buttons and explore the demo. To reset the count, add "/reset" after the url. e.g. <IP address>/reset
@@ -219,15 +262,14 @@ You did it! Click on the buttons and explore the demo. To reset the count, add "
219262
To clean up your cluster, run the following commands:
220263

221264
```bash
222-
set kubeconfig=AKS_WestUS2
223265
kubectl delete deployment shoppingcart-app -n west
224266
kubectl delete service shoppingcart-svc -n west
225-
226-
set kubeconfig=AKS_EastUS
227267
kubectl delete deployment shoppingcart-app -n east
228268
kubectl delete service shoppingcart-svc -n east
229269
```
230270

271+
Proceed with deleting your AKS cluster, your Azure Cache for Redis Enterprise instances and the resource group.
272+
231273
[!INCLUDE [cache-delete-resource-group](includes/cache-delete-resource-group.md)]
232274

233275
## Related Content

0 commit comments

Comments
 (0)