typesense

by Hack The Box

Helm chartv1.1.5App 30.1MITVerified publisher

Deploy Typesense search engine on Kubernetes with Raft-based HA clustering, Prometheus metrics, and Gateway API support. This chart is not officially maintained by or affiliated with the Typesense project.

About this chart

typesense

Disclaimer: This Helm chart is maintained by Hack The Box and is not officially affiliated with or endorsed by the Typesense project. It is provided on a best-effort basis with no guarantees. Use at your own risk.

Overview

A production-ready Helm chart for deploying Typesense, an open-source, typo-tolerant search engine built for instant search. This chart deploys Typesense as a StatefulSet with Raft-based clustering for high availability.

Features

  • High Availability -- Raft-based clustering with odd-replica enforcement (3, 5, 7, ...)
  • Security Hardened -- Non-root container (UID 10000), read-only root filesystem, all capabilities dropped
  • Gateway API & Ingress -- Supports both Kubernetes Ingress and Gateway API (HTTPRoute)
  • Prometheus Metrics -- Optional sidecar exporter with ServiceMonitor support
  • External Secrets -- Optional integration with the External Secrets Operator
  • PodDisruptionBudget -- Protect Raft quorum during node maintenance
  • Comprehensive Tuning -- CORS, analytics, cache, thread pools, logging, health thresholds

TL;DR

helm install typesense oci://ghcr.io/hackthebox/helm/typesense \
  --namespace typesense --create-namespace \
  --set secrets.optional=false

Prerequisites

  • Kubernetes >=1.26.0-0
  • Helm 3.x
  • A pre-created Kubernetes Secret containing at minimum TYPESENSE_API_KEY

Installing the Chart

From OCI Registry

helm install typesense oci://ghcr.io/hackthebox/helm/typesense \
  --namespace typesense --create-namespace \
  --values my-values.yaml

Minimal Example

Create a secret with your Typesense API key:

kubectl create namespace typesense
kubectl create secret generic typesense-secret \
  --namespace typesense \
  --from-literal=TYPESENSE_API_KEY=$(openssl rand -hex 32)

Install with defaults (3-replica HA cluster):

helm install typesense oci://ghcr.io/hackthebox/helm/typesense \
  --namespace typesense \
  --set secrets.optional=false

Production Example

replicaCount: 5

resources:
  requests:
    cpu: 500m
    memory: 2Gi

storage:
  className: gp3
  size: 50Gi

pdb:
  enabled: true
  maxUnavailable: 1

gateway:
  enabled: true
  hosts:
    - search.example.com
  parentRefs:
    default:
      name: my-gateway
      namespace: istio-system

metrics:
  enabled: true
  serviceMonitor:
    enabled: true

secrets:
  optional: false

topologySpreadConstraints:
  - maxSkew: 1
    topologyKey: topology.kubernetes.io/zone
    whenUnsatisfiable: DoNotSchedule
    labelSelector:
      matchLabels:
        app.kubernetes.io/name: typesense

Uninstalling the Chart

helm uninstall typesense --namespace typesense

Note: PersistentVolumeClaims created by the StatefulSet are not deleted automatically. To remove all data:

kubectl delete pvc -l app.kubernetes.io/name=typesense -n typesense

Configuration

Secret Management

Typesense requires at minimum a TYPESENSE_API_KEY environment variable. You have two options:

Option A: Pre-created Secret (default)

Create a Kubernetes Secret and the chart will mount it via envFrom:

kubectl create secret generic typesense-secret \
  --namespace typesense \
  --from-literal=TYPESENSE_API_KEY=your-api-key-here

Option B: External Secrets Operator

If you use the External Secrets Operator, enable the ExternalSecret resource:

secrets:
  externalSecret:
    enabled: true
    storeName: my-secret-store
    extractKey: path/to/typesense/secret

Exposing Typesense

The chart supports both traditional Ingress and the newer Gateway API:

Ingress:

ingress:
  enabled: true
  className: nginx
  hosts:
    - search.example.com
  annotations:
    cert-manager.io/cluster-issuer: letsencrypt-prod

Gateway API (HTTPRoute):

gateway:
  enabled: true
  hosts:
    - search.example.com
  parentRefs:
    default:
      name: my-gateway
      namespace: istio-system

Warning: Enabling both ingress and gateway simultaneously will create duplicate routing resources. Use one or the other unless you have a specific reason to use both.

Monitoring

Enable the Prometheus metrics sidecar and optionally create a ServiceMonitor:

metrics:
  enabled: true
  serviceMonitor:
    enabled: true
    labels:
      release: prometheus

The exporter serves metrics on port 8888 using typesense-prometheus-exporter.

Raft Clustering

Typesense uses the Raft consensus protocol. Key considerations:

  • replicaCount must be odd (1, 3, 5, 7, ...) for quorum. The chart rejects even values > 1.
  • A 3-node cluster tolerates 1 failure. A 5-node cluster tolerates 2 failures.
  • Enable pdb.enabled=true to protect quorum during planned node maintenance.
  • Nodes discover each other via a headless Service and DNS.

Persistence

Data is stored on PersistentVolumeClaims attached to each StatefulSet pod:

storage:
  className: gp3     # omit to use the cluster default StorageClass
  size: 50Gi

Warning: Reducing storage.size after initial deployment has no effect. PVC resize depends on your StorageClass supporting volume expansion.

Values

KeyTypeDefaultDescription
affinityobject{}Affinity rules for pod scheduling. When unset or empty and replicaCount > 1, a soft pod anti-affinity on kubernetes.io/hostname is automatically applied. Set to a non-empty affinity object to override this default behavior.
extraArgslist[]Extra command-line arguments for Typesense server (e.g., ["--filter-by-max-ops=200"])
extraEnvlist[]Extra environment variables for the Typesense container
fullnameOverridestring""Override the full name of the release (optional)
gateway.enabledboolfalseEnable or disable Gateway API for the application
gateway.hostslist[]List of hostnames the Gateway will route traffic for
gateway.parentRefsobject{"default":{"name":"","namespace":"istio-system"},"extras":[]}Configuration controlling which Gateway(s) this HTTPRoute attaches to.
gateway.prefixstring"/"The URL path prefix for the application
image.pullPolicystring"IfNotPresent"Image pull policy (Always, IfNotPresent, etc.)
image.repositorystring"typesense/typesense"Docker image repository for Typesense
image.tagstring""Overrides the image tag. If left empty, it uses the appVersion from Chart.yaml
ingress.annotationsobject{}Extra annotations to add to the Ingress resource
ingress.classNamestring"nginx"The name of the Ingress class to use (e.g., nginx)
ingress.enabledboolfalseEnable or disable Ingress for the application
ingress.hostslist[]List of hostnames the Ingress will route traffic for
ingress.prefixstring"/"The URL path prefix for the application
livenessProbe.failureThresholdint6Number of failed liveness checks before restarting the container
livenessProbe.httpGet.pathstring"/health"
livenessProbe.httpGet.portstring"http"
livenessProbe.periodSecondsint20Period (in seconds) to perform the liveness check
livenessProbe.tcpSocket.portstring"http"
livenessProbe.timeoutSecondsint3
livenessProbe.typestring"tcpSocket"Probe type: 'tcpSocket' or 'httpGet'. Default is tcpSocket to check only that the process is alive and listening. Avoid httpGet /health for liveness: Typesense returns 503 when the write queue exceeds --healthy-write-lag (default 500), which occurs normally during Raft catch-up after a restart, causing a liveness-triggered restart loop that prevents the cluster from ever recovering.
metrics.enabledboolfalseEnable Prometheus metrics sidecar
metrics.image.pullPolicystring"IfNotPresent"Image pull policy for metrics exporter
metrics.image.repositorystring"imatefx/typesense-prometheus-exporter"Metrics exporter image repository
metrics.image.tagstring"v0.1.5"Metrics exporter image tag
metrics.portint8888Port for Prometheus metrics endpoint
metrics.resourcesobject{}Resource requests and limits for the metrics sidecar
metrics.serviceMonitor.enabledboolfalseEnable ServiceMonitor for Prometheus scraping
metrics.serviceMonitor.intervalstring"30s"Scrape interval
metrics.serviceMonitor.labelsobject{}Additional labels for ServiceMonitor
nameOverridestring""Override the name of the release (optional)
nodeSelectorobject{}Node selector to schedule pods on specific nodes (optional)
pdb.enabledbooltrueEnable PodDisruptionBudget for Typesense StatefulSet. Automatically skipped when replicaCount is 1.
pdb.maxUnavailablestring/int"auto"Maximum number of pods that can be unavailable during disruption. Set to "auto" (default) to auto-calculate as floor(replicaCount/2), preserving Raft quorum. Set to 0 to block all voluntary disruptions. Any positive value is used directly and must not exceed floor(replicaCount/2).
podAnnotationsobject{}Additional annotations to add to the Typesense pod(s)
podLabelsobject{}Additional labels to add to the Typesense pod(s)
podSecurityContext.fsGroupint2000Group ID for the filesystem of the Typesense container
podSecurityContext.runAsGroupint3000Group ID for running the Typesense process
podSecurityContext.runAsNonRootbooltrueEnsure the container does not run as root
podSecurityContext.runAsUserint10000User ID for running the Typesense process
readinessProbe.failureThresholdint12Number of failed readiness checks before marking the pod as unready
readinessProbe.httpGet.pathstring"/health"
readinessProbe.httpGet.portstring"http"
readinessProbe.periodSecondsint10Period (in seconds) to perform the readiness check
readinessProbe.tcpSocket.portstring"http"
readinessProbe.timeoutSecondsint3
readinessProbe.typestring"httpGet"Probe type: 'httpGet' or 'tcpSocket'
replicaCountint3Number of replicas for the Typesense deployment
resourcesobject{"requests":{"cpu":"2000m"}}Resource requests and limits for the Typesense container. Typesense requires at least 2 vCPUs to operate correctly. No CPU limit is set by default to avoid throttling during indexing and Raft catch-up.
secrets.externalSecret.enabledboolfalseEnable or disable ExternalSecret creation (requires external-secrets operator)
secrets.externalSecret.extractKeystring""The key path to extract secrets from
secrets.externalSecret.storeNamestring""The name of the ClusterSecretStore or SecretStore to use
secrets.optionalbooltrueWhether the secretRef in envFrom is optional (pods start even if secret is missing)
secrets.secretNamestring""Name of the Kubernetes Secret to mount via envFrom. Defaults to -secret
securityContext.allowPrivilegeEscalationboolfalsePrevent privilege escalation
securityContext.capabilitiesobject{"drop":["ALL"]}Drop all Linux capabilities
securityContext.readOnlyRootFilesystembooltrueRead-only root filesystem (Typesense only writes to data PVC)
service.portint8108Port that the Typesense service will listen on
service.typestring"ClusterIP"Kubernetes service type (ClusterIP, NodePort, LoadBalancer)
serviceAccount.annotationsobject{}Annotations to add to the ServiceAccount (e.g., for IRSA)
serviceAccount.automountServiceAccountTokenboolfalseWhether to automount the ServiceAccount token
serviceAccount.createbooltrueWhether to create a ServiceAccount
serviceAccount.namestring""Name of the ServiceAccount. Defaults to fullname
startupProbe.failureThresholdint60Number of failed startup checks before marking the container as unhealthy
startupProbe.httpGet.pathstring"/health"
startupProbe.httpGet.portstring"http"
startupProbe.periodSecondsint10Period (in seconds) to perform the startup check
startupProbe.tcpSocket.portstring"http"
startupProbe.timeoutSecondsint3
startupProbe.typestring"httpGet"Probe type: 'httpGet' or 'tcpSocket'
storage.classNamestringnilStorage class to use for Persistent Volume Claims (PVC)
storage.sizestring"10Gi"Size of the persistent storage volume (e.g., 10Gi)
terminationGracePeriodSecondsint300Termination grace period in seconds. Typesense recommends 300s to allow graceful shutdown.
tolerationslist[]Tolerations for pod scheduling
topologySpreadConstraintslist[]Topology spread constraints for pod distribution across nodes/zones
typesense.analytics.enabledboolfalseEnable aggregated search query analytics
typesense.analytics.fl

Deploy typesense with OpenTenant

Each tenant gets its own release of this chart, with its own namespace, secrets and domain. The builder below already has typesense on a Hetzner server. Change the host, add apps from the marketplace, then copy the generated files. Providers and prices are samples, and nothing here is sent anywhere.

  1. Pick a serverConnect Hetzner, OVHcloud or AWS. The builder starts on Hetzner, the cheapest sample rate.
  2. Place the charttypesense is pinned at v1.1.5 in opentenant.yaml. Drag more apps from the marketplace onto a rack.
  3. ApplySave opentenant.yaml and main.tf from the console, then run the commands below.
# opentenant.yaml, main.tf and dns.tf come from the builder below
opentenant validate opentenant.yaml
terraform init && terraform apply