Use Azure Redis Cache with the Online Boutique sample on AKS

Mathieu Benoit
4 min readJun 27, 2023

--

By default the cartservice of the Online Boutique sample stores its data in an in-cluster Redis database. Using a fully managed database service outside your Kubernetes cluster such as Memorystore (Redis) could bring more resiliency, scalability and more security. If you want to see this in action you can look at this previous blog post I wrote: Use Google Cloud Memorystore (Redis) with the Online Boutique sample on GKE.

What’s really interesting with the Online Boutique sample is that it is not just used on Google Cloud, but could also be used on AWS and Azure.

Online Boutique is a cloud-first microservices demo application. Online Boutique consists of an 11-tier microservices application. The application is a web-based e-commerce app where users can browse items, add them to the cart, and purchase them.

Online Boutique is composed of 11 microservices written in different languages (.NET, Java, Python, Go and NodeJS) that talk to each other over gRPC.

In this new blog post, let’s see how you can easily connect the Online Boutique sample deployed on an Azure Kubernetes Service (AKS) cluster to Azure Redis Cache.

Objectives

  • Create a Azure Kubernetes Service (AKS) cluster
  • Provision an Azure Redis Cache instance
  • Deploy the Online Boutique sample (via its Helm chart) connected to the Azure Redis Cache instance

Costs

This tutorial uses billable components of Azure, including the following:

Use the pricing calculator to generate a cost estimate based on your projected usage.

Set up your environment

Initialize the common variables used throughout this tutorial:

RESOURCE_GROUP=azure-redis-with-onlineboutique
LOCATION=canadacentral

Create a dedicated Azure resource group:

az group create \
-n ${RESOURCE_GROUP}\
-l ${LOCATION}

Enable the required providers

az provider register \
-n Microsoft.ContainerService
az provider register \
-n Microsoft.Cache

Create an AKS cluster

CLUSTER=azure-redis-with-onlineboutique
az aks create \
-g ${RESOURCE_GROUP} \
-n ${CLUSTER_NAME} \
-l ${LOCATION} \
--generate-ssh-keys

Provision the Azure Redis Cache instance

REDIS_NAME=azure-redis-with-onlineboutique
REDIS_SKU="basic"
REDIS_SIZE="C0"

az redis create \
-n ${REDIS_NAME} \
-g ${RESOURCE_GROUP} \
-l ${LOCATION} \
--sku ${REDIS_SKU} \
--vm-size ${REDIS_SIZE}

Wait for the Azure Redis Cache instance to be succesfully provisioned and then get the connection information (redis host address, SSL port and authentication string):

REDIS_HOST=$(az redis show \
-n ${REDIS_NAME} \
-g ${RESOURCE_GROUP} \
--query [hostName] \
-o tsv)
REDIS_PORT=$(az redis show \
-n ${REDIS_NAME} \
-g ${RESOURCE_GROUP} \
--query [sslPort] \
--output tsv)
REDIS_AUTH=$(az redis list-keys \
-n ${REDIS_NAME} \
-g ${RESOURCE_GROUP} \
--query [primaryKey] \
--output tsv)

Deploy Online Boutique connected to the Azure Redis Cache instance

Deploy the Online Boutique sample apps without the default in-cluster Redis database, and now pointing to the Azure Redis Cache instance:

NAMESPACE=onlineboutique
helm upgrade onlineboutique oci://us-docker.pkg.dev/online-boutique-ci/charts/onlineboutique \
--install \
--create-namespace \
-n ${NAMESPACE} \
--set frontend.platform=azure \
--set cartDatabase.inClusterRedis.create=false \
--set cartDatabase.connectionString="${REDIS_HOST}:${REDIS_PORT}\,abortConnect=false\,ssl=true\,password=${REDIS_AUTH}"

Note: --set frontend.platform=azure is just to have the Azure label on the Online Boutique website.

After all the apps have successfully been deployed, you could navigate to the Online Boutique website by clicking on the link below:

echo -n "http://" && kubectl get svc frontend-external -n ${NAMESPACE} -o json | jq -r '.status.loadBalancer.ingress[0].ip'

And voilà, that’s how easy you can connect your Online Boutique sample apps to an Azure Redis Cache database, congrats!

Cleaning up

To avoid incurring charges to your Azure account, you can delete the resources used in this tutorial.

Delete the AKS cluster:

az aks delete \
-n ${CLUSTER_NAME} \
-g ${RESOURCE_GROUP}

Delete the Azure Redis Cache instance:

az redis delete \
-n ${REDIS_NAME} \
-g ${RESOURCE_GROUP}

Delete the Azure resource group:

az group delete ${RESOURCE_GROUP}

Conclusion

Having the database outside of your Kubernetes cluster with a managed service, like Google Cloud Memorystore (Redis) or Azure Redis Cache can bring you more resiliency, scalability and security. This setup allows complex scenarios like having your apps spreaded across multiple clusters, etc.

Today, we demonstrated that you could easily use the Online Boutique sample also on Azure (even if created and actively maintained by Google Cloud).

Happy demoing, happy sailing! 🚀

--

--

Mathieu Benoit

Customer Success Engineer at Humanitec | CNCF Ambassador | GDE Cloud