According to the Installation Guide for a Sitecore Production Deployment with Kubernetes, we have to use external services for SQL service, Solr cloud, and Redis cache. While the documentation describes how to initialize data for the SearchStax provider for Solr, it says nothing about how to configure Sitecore to use services such as Azure SQL with Elastic Pool and Azure Redis. This article describes what needs to be done.
Azure SQL with Elastic Pool
Once we have Kubernetes Cluster and Azure SQL installed, we need to allow them to communicate with each other. First of all, subnet should be added to vNet:
1. Go to the Resource Group where you have AKS installed, find your Virtual network definition and open it:
2. In the left sidebar find Subnets, open it and add a new one:
Make sure that Microsoft.Sql is selected in the Services dropdown.
3. Go to the Resource Group where you have SQL server installed, find and open it:
4. Copy Server name, Server admin and save somewhere. We will need it later.
5. Find Firewalls and virtual networks In the left side menu
-
Set Yes for Allow Azure services and resources to access this server.
-
Click + Add existing virtual network and select previously created subnet.
-
If you want to access SQL Service from your local machine or network, add a range of IP addresses to allow.
6. Go to the Resource Group where you have Elastic Pool installed, find and open it:
7. Copy Elastic Pool Name:
8. Now need to update our secrets:
-
Set SQL Server name copied earlier to the sitecore-databaseservername.txt secret (mssql is a secret default value)
-
Set Server admin name copied earlier to the sitecore-databaseusername.txt secret. It can be another user but with Admin permissions.
-
Set Server admin password to the sitecore-databasepassword.txt secret. The password is usually set during the SQL Server set up. You can also reset it in Azure Portal.
-
Set SQL elastic pool name copied earlier to the sitecore-database-elastic-pool-name.txt secret.
Azure Cache for Redis
There is only one connection string (for CM and CD roles) that needs to be updated to allow our Sitecore instance to use Redis Cache hosted in Azure. Once all our connection strings are managed in environment variables defined in k8s yaml files, we can simply change that. Variable that includes a Redis connection string called Sitecore_ConnectionStrings_Redis.Sessions. The default value looks like below:
We can update the connection string straight away in a yaml file still keeping that hardcoded, but I would like to suggest you add a new secret file and move the value there.
1. Go to the folder where your secrets are and add a new sitecore-redis-connection-string.txt file.
2. Open secrets customization.yaml file and add the following:
- name: sitecore-redis files: - sitecore-redis-connection-string.txt |
3. Open cd.yaml file and update the Sitecore_ConnectionStrings_Redis.Sessions environment variable:
- name: Sitecore_ConnectionStrings_Redis.Sessions secretKeyRef: name: sitecore-redis key: sitecore-redis-connection-string.txt |
4. Do the same for cm.yaml
5. Go to the Resource Group where you have Azure Cache for Redis installed, find and open it:
6. Copy its Host name:
6. Now need to update our secret file:
- Set the Host name copied above to the sitecore-redis-connection-string.txt secret.
6. Redeploy your secrets and cm,cd pods.