Deploy Sitecore XP to the Azure Kubernetes Service

Version: 10.5

This section describes the steps you need to perform to deploy Sitecore Experience Platform to the Azure Kubernetes Service. You must perform the steps in the order they are described here.

Deploy external data services

In production deployments, you must deploy the required external services before you deploy the Sitecore containers in Kubernetes.

The required external services are:

  • Microsoft SQL Server or SQL Azure Database Elastic Pool
  • Apache Solr (SolrCloud mode)
  • RedisLabs Redis

In non-production deployments you can create the external services inside the K8s cluster. For more information, see the section Deploy external services for a non-production deployment.

Create an AKS cluster

To create a new Azure Kubernetes Service (AKS) cluster with a Windows Server node pool, use the Azure command-line interface (Azure CLI) or the Azure portal UI. The AKS cluster must contain one Windows Server 2022 or later node pool with one or more nodes.

For more information about using the Azure CLI to create an AKS cluster, see the Azure AKS documentation.

Configure the Kubectl context cluster

To configure the Kubectl context cluster:

  1. Log in to the Azure CLI and set a subscription. For example:

    
    az login
    az account set --subscription "Your Subscription"
    
  2. Get the credentials for the K8s cluster that were created with the AKS cluster and save them locally. For example:

    az aks get-credentials --resource-group sc10aks --name sc10cluster

Deploy an ingress controller

To deploy an ingress controller:

  1. Use the Windows AMD64 binaries to Install Helm. You can also use an alternative method as described in Installing Helm Through Package Managers.

  2. Add an NGINX ingress controller feed to Helm. For example: helm repo add ingress-nginx

  3. Use Helm to deploy the NGINX ingress controller. For example:

    
    helm install nginx-ingress ingress-nginx/ingress-nginx --wait `
      --set controller.replicaCount=2 `
      --set controller.nodeSelector."kubernetes\.io/os"=linux  `
      --set defaultBackend.nodeSelector."kubernetes\.io/os"=linux `
      --set controller.admissionWebhooks.patch.nodeSelector."kubernetes\.io/os"=linux `
      --set controller.service.externalTrafficPolicy=Local
    
    Note

    In ./ingress-nginx/ingress.yaml, the nginx.ingress.kubernets.io/proxy-body-size annotation limits payload requests, such as media data upload or Sitecore packages installation, to 512 MB. You can adjust this to fit your installation. For more information about ingress configuration, see NGINX Ingress Controller Configuration. If you need more than 512 MB, you must also adjust the maxRequestLength setting in the httpRuntime node in the Sitecore web.config file.

  4. From the root folder of your chosen topology, run this command:

    kubectl apply -k ./ingress-nginx/

Add grant a 'Contributor' access to your resource group for the Managed Identity

During the deploying Sitecore to the k8s you can face with the issue “failed mount volume“ for “cd, cm“ pods:

Warning: FailedMount 18m (x9 over 28m) kubelet MountVolume.MountDevice failed for volume "pvc-XXXX".The client '{client_id}' with object id '{object_id}' does not have authorization to perform action 'Microsoft.Storage/storageAccounts/listKeys/action' over scope '/subscriptions/{subscription_id}/resourceGroups/{resource_group_name}/providers/Microsoft.Storage/storageAccounts/{storage_account_id}' or the scope is invalid. If access was recently granted, please refresh your credentials.

To solve this issue, you need to grant a “Contributor“ access to your resource group for the Managed Identity:

  1. Get the object id (assignee) using the Managed Identity of the Kubernetes cluster node pool in the resource group scope

    $assignee = az aks show -g [resource_group_name] -n [cluster_name] --query identityProfile.kubeletidentity.objectId | ConvertFrom-Json

  2. Get the node resource group name using the Managed Identity of the Kubernetes cluster node pool in the resource group scope

    $nodeResourceGroupName = az aks show -g [resource_group_name] -n [cluster_name] --query nodeResourceGroup | ConvertFrom-Json

  3. Assign the 'Contributor' role to Kubernetes cluster node pool in the node resource group name for the resource group scope

    az role assignment create --assignee-object-id [assignee] --assignee-principal-type “ServicePrincipal“ --role "Contributor" --scope "/subscriptions/[subscription_id]/resourceGroups/[node_resource_group_name]"

    Where:

    • [resource_group_name] is your resource group name
    • [cluster_name] is your cluster name
    • [assignee] is your object id for the Managed Identity
    • [subscription_id] is your subscription id
    • [node_resource_group_name] is your node resource group name

Deploy the secrets

To deploy the secrets:

  1. Ensure that all the secrets files (.txt, .crt, .key) files in the /secrets and overrides\<topology>\secrets folders are updated according to the requirements listed in The Kubernetes Secrets list.

  2. From the folder of your chosen topology, run this command:

    kubectl apply -k ./secrets/

Deploy external services for a non-production deployment

In production environments you must deploy external services outside the Kubernetes cluster. However, in non-production environments you can deploy the services inside the Kubernetes cluster.

To deploy external services for a non-production deployment:

  1. From the folder of your chosen topology, run this command:

    kubectl apply -k ./external/
  2. To check the status of the pods, run this command:

    kubectl get pods -o wide
  3. To wait until the status of all the pods is Running/OK, run this command:

    
    kubectl wait --for=condition=Available deployments --all --timeout=900s
    kubectl wait --for=condition=Ready pods --all
    

Deploy the data initialization jobs

To deploy the data initialization jobs:

  1. If you use SearchStax as your SolrCloud provider, follow the instructions in Initialize data for SearchStax provider for Solr. If you do not use Searchstax, navigate to the folder of your chosen topology, and run this command:

    kubectl apply -k ./init/
  2. To check the status of the jobs, run this command:

    kubectl get jobs -o wide
  3. To wait until the status of all the jobs is Complete/OK, run this command:

    
    kubectl wait --for=condition=Complete job.batch/solr-init --timeout=900s
    kubectl wait --for=condition=Complete job.batch/mssql-init --timeout=900s
    

Deploy a persistent volume claim

To deploy a persistent volume claim, run this command:

kubectl apply -f ./volumes/azurefile

Deploy the Sitecore pods

To deploy the Sitecore pods:

  1. From the folder of your chosen topology, run this command:

    kubectl apply -k ./
  2. To check the status of the pods, run this command:

    kubectl get pods -o wide
  3. To wait until the status of all the pods is Running/OK, run this command:

    kubectl wait --for=condition=Available deployments --all --timeout=1800s

Update the local host file

To update the local host file:

  1. To obtain the external IP address of the ingress controller service for the CM role, run this command:

    kubectl get ingress
  2. Update the local host file with the external IP address and the hostnames that are required by the ingress controller. The default hostnames are:

    • cm.globalhost
    • cd.globalhost
    • Id.globalhost

Configure the SolrCloud search indexes

When you have finished deploying the containers, you must update all the search indexes.

To configure the SolrCloud search indexes:

  1. Open a browser and navigate to https://cm.globalhost/sitecore.
  2. Log in to Sitecore with the admin user and password that you configured as a secret.
  3. In the Sitecore Control Panel click Populate Managed Schema. In the Schema Populate dialog box, select all the indexes and click Populate.
  4. In the Sitecore Control Panel, in the Indexing section, click Indexing Manager.
  5. In the Indexing Manager dialog box, select the indexes you want to rebuild, and then click Rebuild.
  6. When the search indexes have been rebuilt, click Close.
If you have suggestions for improving this article, let us know!