Deploy typesense search to kubernetes
Run algolia alternative as self hosted k8s app
Document search has emerged as a quintessential feature for a myriad of websites, from content-heavy blogs and documentation pages to e-commerce platforms. A robust search functionality enhances user experience, allowing users to effortlessly navigate and access the information they need.
Algolia, a popular hosted search engine, has long been a go-to solution for many developers. However, the open-source ecosystem offers self-hosted alternatives like Typesense that give developers more control, customization, and transparency. In this article, we'll explore the importance of document search, the benefits of open-source, and how to deploy Typesense on Kubernetes.
The Importance of Document Search
In the vast sea of information that the internet has become, the importance of efficient navigation cannot be overstated. Here's why document search is pivotal:
- Enhanced User Experience: Users no longer have the patience to navigate through a site's hierarchy or use generic search tools that return irrelevant results. An effective search tool understands user intent, offering accurate results swiftly.
- Increased Engagement: When users can quickly find what they're looking for, they're more likely to stay on your website, reducing bounce rates.
- Maximized Content Value: No matter how high-quality or valuable your content is, it loses its value if users can't find it. An efficient search tool ensures that your content is accessible and easy to discover.
Why Open Source?
Open source software (OSS) like Typesense offers several benefits:
- Transparency: You have complete visibility into the software's codebase, understanding how it works, and ensuring there are no hidden surprises.
- Flexibility and Customization: Open-source tools can be modified to suit specific needs, allowing for unparalleled customization.
- Community Support: A vibrant community often backs OSS, providing support, plugins, extensions, and regular updates.
- Cost-Effective: While not always free, open-source tools often offer more cost-effective solutions than proprietary software, especially at scale.
Deploying Typesense on Kubernetes
Now that we understand the significance of document search and the advantages of open-source, let's dive into deploying Typesense on Kubernetes.
1. Persistent Storage
Firstly, we need a persistent volume to store Typesense's data, ensuring data persistence across restarts.
apiVersion: v1 kind: PersistentVolume metadata: name: typesense-data-pv namespace: metrics labels: type: local spec: storageClassName: "gp3" capacity: storage: 10Gi accessModes: - ReadWriteOnce hostPath: path: "/mnt/data"
Once the volume is set, we create a Persistent Volume Claim (PVC) to request storage from the volume:
apiVersion: v1 kind: PersistentVolumeClaim metadata: name: typesense-data-pvc namespace: metrics spec: storageClassName: "gp3" accessModes: - ReadWriteOnce resources: requests: storage: 10Gi selector: matchLabels: type: local
2. Deploying Typesense
Now, we'll deploy Typesense using the following configuration:
apiVersion: apps/v1 kind: Deployment metadata: name: typesense namespace: metrics spec: replicas: 1 selector: matchLabels: app: typesense template: metadata: namespace: metrics labels: app: typesense spec: containers: - name: typesense image: typesense/typesense:0.25.1 args: ["--data-dir", "/data", "--api-key=africa", "--enable-cors"] ports: - containerPort: 8108 volumeMounts: - mountPath: /data name: typesense-data volumes: - name: typesense-data persistentVolumeClaim: claimName: typesense-data-pvc
3. Exposing Typesense
Lastly, we need a service to expose Typesense, making it accessible:
apiVersion: v1 kind: Service metadata: name: typesense-service namespace: metrics spec: selector: app: typesense ports: - protocol: TCP port: 8108 targetPort: 8108 type: NodePort
Document search is paramount in today's digital landscape, and open-source solutions like Typesense offer a transparent, customizable, and community-backed alternative to services like Algolia. With the power of Kubernetes, deploying and scaling Typesense becomes a breeze, ensuring your website's users always find what they're looking for.