Skip to content

Instantly share code, notes, and snippets.

@perosb
Last active June 18, 2021 11:37
Show Gist options
  • Save perosb/f6a6010b095011a902702286940a98e6 to your computer and use it in GitHub Desktop.
Save perosb/f6a6010b095011a902702286940a98e6 to your computer and use it in GitHub Desktop.
Sitecore Container with SolrCloud SwitchOnRebuild

Sitecore Containers + SolrCloud with SwitchOnRebuild

The default solr-init container doesn't create any rebuild cores. So create them you need to modify the Start.ps1 script in the solr-init Dockerfile.

# escape=`

ARG PARENT_IMAGE

FROM ${PARENT_IMAGE}

# Add all our custom scripts
COPY ./scripts/*.ps1 /

Extract the Start.ps1 file some your solr-init container. You probably need to start the container locally and then copy the file. For example docker run -ti --entrypoint powershell scr.sitecore.com/sxp/nonproduction/sitecore-xm1-solr-init:10.0-20H2 and then copy the file using either docker cp or some other UI based tool.

In your custom Start.ps1, around line 88, replace/edit the New-SolrCore.ps1 line with

.\New-SolrCore.ps1 -SolrCoreNames "$($solrCoreName)_1" -SolrEndpoint $SolrEndpoint -SolrCorePrefix $SolrCorePrefix -SolrConfigsetName $solrConfigsetName -SolrReplicationFactor $SolrReplicationFactor -SolrNumberOfShards $SolrNumberOfShards -SolrMaxShardNumberPerNode $SolrMaxShardsPerNodes
.\New-SolrCore.ps1 -SolrCoreNames "$($solrCoreName)_2" -SolrEndpoint $SolrEndpoint -SolrCorePrefix $SolrCorePrefix -SolrConfigsetName $solrConfigsetName -SolrReplicationFactor $SolrReplicationFactor -SolrNumberOfShards $SolrNumberOfShards -SolrMaxShardNumberPerNode $SolrMaxShardsPerNodes

The only change is the added postfix to the cores, "$($solrCoreName)_1". Use these 1 and 2 cores when you follow the Sitecore documentation for patching in the SwitchOnRebuild providers.

Note: Sitecore XC comes with rebuild out of the box.

Last thing - the default k8s specifications have a dynamic value for InstanceName. This will break SwitchOnRebuild as Sitecore CM stores the active/rebuild collection in Properties table. When you make a new deployment the replicaset id changes and sitecore reverts back to index_1. So you need to explicitly set InstanceName to f.ex. "cm". Sitecore/container-deployment#34

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment