Setting up Apache Solr on Kubernetes (with Rancher Desktop)

Dan Niles
4 min readJan 13, 2024

--

Solr is a popular, blazing-fast, open-source enterprise search platform built on Apache Lucene™. Solr exhibits exceptional reliability, scalability, and fault tolerance. It offers distributed indexing, replication, and load-balanced querying, along with automated failover and recovery, centralized configuration, and additional features.

In this tutorial, we’ll see how we can set up Apache Solr on Kubernetes with Rancher Desktop. Rancher Desktop is an alternative to Docker Desktop which has Kubernetes included with it. When installed, you will have access to the following supporting utilities: helm, kubectl, nerdctl and docker.

Installing Rancher Desktop

As the first step, go ahead and install Rancher Desktop following the instructions from the following link:

After installing Rancher Desktop, make sure to enable Kubernetes in the preferences menu. Also, disable Traefik as we will be using ingress-nginx in this tutorial.

Enable Kubernetes and disable Traefik

Most Linux distributions (e.g. Ubuntu 20.04) do not allow non-root users to listen on TCP and UDP ports below 1024. To allow our NGINX controller to listen to privileged ports on the local host, add the following line to your /etc/sysctl.conf file.

net.ipv4.ip_unprivileged_port_start=80

Installing the Ingress NGINX Controller

By default, Kubernetes services are only accessible within the cluster. To make them accessible from our local machine, we’ll incorporate an ingress controller.

# Install the nginx ingress controller
$ helm upgrade --install ingress-nginx ingress-nginx \
--repo https://kubernetes.github.io/ingress-nginx \
--namespace ingress-nginx --create-namespace

# Inspect that the ingress controller is running by visiting the Kubernetes dashboard
# and selecting namespace `ingress-nginx`, or running this command:
$ kubectl get all --namespace ingress-nginx

Edit your /etc/hosts file and replace the 127.0.0.1 line with the following line. Once we have installed Solr to our k8s, this will allow us to address the nodes locally.

127.0.0.1	localhost default-<CLOUD>-solrcloud.ing.local.domain ing.local.domain default-<CLOUD>-solrcloud-0.ing.local.domain default-<CLOUD>-solrcloud-1.ing.local.domain default-<CLOUD>-solrcloud-2.ing.local.domain dinghy-ping.localhost

Where <CLOUD> can be any name you like. This will be the name of your SolrCloud deployment. Be sure to replace it in every place it appears in this tutorial.

Installing the Solr Operator

Let’s now install the Solr Operator which will let us easily manage a large Solr cluster. Add the Solr Operator Helm repository with the following command,

$ helm repo add apache-solr https://solr.apache.org/charts
$ helm repo update

Next, install the Solr Operator chart. (This will install the Zookeeper Operator by default)

# Install the Solr & Zookeeper CRDs
$ kubectl create -f https://solr.apache.org/operator/downloads/crds/v0.8.0/all-with-dependencies.yaml

# Install the Solr operator and Zookeeper Operator
$ helm install solr-operator apache-solr/solr-operator --version 0.8.0

Starting an example Solr Cloud cluster

To start a Solr Cloud cluster, execute the following command which will tell the Solr Operator what version of Solr Cloud to run, how many nodes, with how much memory etc.

# Create a 3-node cluster v8.11 with 300m Heap each:
$ helm install <CLOUD>-solr apache-solr/solr --version 0.8.0 \
--set image.tag=9.4 \
--set solrOptions.javaMemory="-Xms300m -Xmx300m" \
--set addressability.external.method=Ingress \
--set addressability.external.domainName="ing.local.domain" \
--set addressability.external.useExternalAddress="true" \
--set ingressOptions.ingressClassName="nginx"

# The solr-operator has created a new resource type 'solrclouds' which we can query
# Check the status live as the deployment happens
$ kubectl get solrclouds -w

Open a web browser to see a Solr node:

# Note that this is the service level, so it will round-robin between the nodes
$ open "http://default-<CLOUD>-solrcloud.ing.local.domain/solr/#/~cloud?view=nodes"

And there you go! Now you have Apache Solr running on Kubernetes on your local machine.

If you need to scale up/down, run the following command, mentioning your desired number of replicas:

$ kubectl scale --replicas=5 solrcloud/<CLOUD>

After issuing the scale command, You can also view the status via the kubectl get solrclouds command:

$ kubectl get solrclouds -w

To uninstall your SolrCloud deployment, run the following command:

$ helm uninstall <CLOUD>-solr

I hope you found this tutorial helpful. If you encounter any issues, please leave a comment below, and I’ll be happy to assist!

References

--

--

Dan Niles
Dan Niles

Written by Dan Niles

Computer Science & Engineering Undergraduate @ University of Moratuwa, Sri Lanka

Responses (2)