/typesense-helm

Typesense Helm Chart for installing HA Typesense Clusters on Kubernetes

Primary LanguageSmartyGNU General Public License v3.0GPL-3.0

Typesense Helm Charts

Typesense is an open-source search engine, alternative to Algolia, known for its speed and typo-tolerance, providing a fast and user-friendly search experience. It supports real-time indexing, faceted search, and full-text search, making it ideal for applications needing robust search capabilities. With simple APIs and SDKs for easy integration, Typesense is also optimized for performance with large datasets. It supports multiple languages and can be set up in a clustered environment for high availability and scalability.

Note

This an unofficial Helm Chart.

Components

The following components will be installed using this Helm Chart:

Typesense

  • EveryPod will be installed with two containers (default replica count for the pods is set to 3). Typesense itself (version 27.1) and the Typesense Peer Resolver as a sidecar--see below.
  • a headless Service (stems from the fact that Typesense needs to be installed as StatefulSet).
  • A number of PersistentVolumeClaim and PersistentVolume objects; their number match the replica count.

Note

This Helm Chart is unopinionated on how you are going to expose Typesense or Typesense Dashboard services, and that's why no LoadBalancer or Ingress solution is provided. Nevertheless, it is strongly recommended not exposing Typesense service out of the cluster as is, but use a reverse proxy instead.

Typesense Peer Resolver for Kubernetes

Typesense Peer Resolver is a sidecar container for Typesense, that automatically resets the nodes peer list for HA Typesense clusters in Kubernetes by identifying the new endpoints of the headless service. When restarting/upgrading Typesense nodes in a high-availability cluster scenario running in Kubernetes, DNS entries of the StatefulSet do not get resolved again with the new IP, preventing the pods/peers to rejoin the cluster, even if you have the TYPESENSE_RESET_PEERS_ON_ERROR flag enabled. With this sidecar, we do not need to provide a node list to Typesense in order because the sidecar will create one on the fly and update the necessary file in the mount that shares with the Typesense container (remember they live in the same pod).

Typesense Peer Resolver will additionally install:

  • a Kubernetes ServiceAccount
  • a Kubernetes Role that grants get, list and watch permission for Endpoints
  • a Kubernetes RoleBinding

Note

For more information on Typesense Peer Resolver check the repository of the project:

DocSearch Scraper

The Helm Chart installs the customized version of DocSearch that works with Typesense as a CronJob. It will periodically crawl and scrape the site(s) defined in start_urls of the config.json configuration file of the scraper. An additional ConfigMap is installed, that holds the value of the config.json configuration file required from DocSearch Scraper. You can provide you own configuration via the scraper.config value of the Helm Chart. The value should be in JSON format, but passed as string.

Caution

If you enable the scraper, it will provision a scaffold config.json in the accompanying ConfigMap, and every Job spawned from the CronJob will exit as Failed. This doesn't mean that the DocSearch Scraper is not installed correctly, it is absolutely normal; it is just missing the required parameters to crawl your target site(s). More information on how to create and configure your own config.json file can be found here.

Typesense Dashboard

Typesense Dashboard is a very interesting open-source project that lets you manage and browse collections from a Web UI. More information on the project repository.

The chart will install a Deployment and a Service for this component. It is up to you how to expose it.

Deployment

Requirements

Only requirement (except a Kubernetes cluster of course ) is Helm and this can be installed with the following ways:

curl -fsSL -o get_helm.sh https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3
chmod 700 get_helm.sh
/get_helm.sh

or via brew:

brew install helm

Parameters

Property Required default
typesense.apiKey true
typesense.apiPort true 8108
typesense.peeringPort true 8107
typesense.protocol true http
typesense.cors.enabled true
typesense.cors.domains ""
typesense.resetPeersOnError true
storage.size true 10Gi
storage.storageClassName true default
typesense.replicas true 3
scraper.enabled false
scraper.schedule true '*/2 * * * *'
scraper.config true see charts/typesense/values.yaml
dashboard.enabled true
dashboard.replicas 1

Installing the chart

helm repo add typesense-unofficial https://akyriako.github.io/typesense-helm
helm repo update

helm upgrade --install $RELEASE_NAME typesense-unofficial/typesense \
    --set typesense.apiKey=$ADMIN_API_KEY \
    -n $NAMESPACE \
    --create-namespace 

Tip

You can easily create a random admin API key with the following command:

sudo apt install rand -y
export ADMIN_API_KEY=$(openssl rand -base64 14)

Uninstalling the chart

helm uninstall $RELEASE_NAME -n $NAMESPACE