Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single pod and HorizontalPodAutoscaler Example #3

Open
hadminh opened this issue Jan 31, 2022 · 5 comments
Open

Single pod and HorizontalPodAutoscaler Example #3

hadminh opened this issue Jan 31, 2022 · 5 comments

Comments

@hadminh
Copy link

hadminh commented Jan 31, 2022

Thanks for an awesome software and example.

This is more of a help request.

I am a startup company, and High Availability is too expensive for me, as I am dealing with a large dataset. I have about 3.2 million records similar to your airbnb example. Note that I am also self-hosting the map tiles server on the same node IoI

The example here requires to manually modify the ConfigMap and increment
typesense-{increment}.ts.typesense.svc.cluster.local:8107:8108
based on how many replicaset I have.

To be honest I am using Kubernetes only for its autoscaling capabilities.
(I mean Kubernetes without autoscaling capability doesn't worth the effort :) )

Is it possible to make a single Statefulset pod of a Typesense and horizontally auto scale it? Can it choose the typesense-0 as a master and the rest for read access, without any configuration?

@Bug-Reaper
Copy link

+1 for more examples on auto-scale config.

@mojtabacazi
Copy link

+1

@sagungargs15
Copy link

+1 can you help with a helm chart example for installation or something beyond what is offered in the above

@hadminh
Copy link
Author

hadminh commented Feb 3, 2023

Not sure if you were asking me but the YouTube link I posted below is the best resource to learn about Statefulsets.

https://www.youtube.com/watch?v=eUa-IDPGL-Q

The Typesense helm chart basically creates a highly available or HA Statefulset of Typesense pods.
In the video, the instructor talks about mongo-db master/slave or leader/follower relationship. The very concept can be applied to Typesense.
This config map from the helm chart defines that relationship.

apiVersion: v1
kind: ConfigMap
metadata:
  name: nodeslist
  namespace: typesense
data:
  nodes: "typesense-0.ts.typesense.svc.cluster.local:8107:8108,typesense-1.ts.typesense.svc.cluster.local:8107:8108,typesense-2.ts.typesense.svc.cluster.local:8107:8108" 

@hadminh
Copy link
Author

hadminh commented Feb 3, 2023

The simplest method to run Typesense in Kubernetes is by using a Deployment, not a Statefulset. I chose this option as it is more straightforward to set up, as demonstrated in the provided deployment example.

apiVersion: v1
kind: Service
metadata:
  name: typesense-service
spec:
  selector:
    app: typesense
  ports:
    - name: port
      protocol: TCP
      port: 8108
      targetPort: 8108
---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: typesense-depl
spec:
  replicas: 1
  selector:
    matchLabels:
      app: typesense
  template:
    metadata:
      labels:
        app: typesense
    spec:
      containers:
        - name: typesense
          # NOTE : you can update to the latest release
          image: typesense/typesense:0.23.1
          command:
            - "/opt/typesense-server"
            - "-d"
            - "/usr/share/typesense/data"
            - "--api-key"
            - "xyz"
            - "--api-port"
            - "8108"
          ports:
            - containerPort: 8108
              name: http
          volumeMounts:
            - name: typesense-storage
              mountPath: /usr/share/typesense/data
      volumes:
        - name: typesense-storage
          emptyDir:
            sizeLimit: 1Gi

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants