Skip to content

Instantly share code, notes, and snippets.

@maltoe
Created February 19, 2025 11:52
Show Gist options
  • Save maltoe/efbee049c9cb47e7b08fee25a20f64de to your computer and use it in GitHub Desktop.
Save maltoe/efbee049c9cb47e7b08fee25a20f64de to your computer and use it in GitHub Desktop.
Typesense K8s config
apiVersion: v1
kind: Namespace
metadata:
name: typesense
---
apiVersion: v1
kind: ConfigMap
metadata:
name: nodes
namespace: typesense
data:
nodes: typesense-0.typesense-peering.typesense.svc.cluster.local:8107:8108,typesense-1.typesense-peering.typesense.svc.cluster.local:8107:8108,typesense-2.typesense-peering.typesense.svc.cluster.local:8107:8108
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: typesense
labels:
app: typesense
spec:
serviceName: typesense-peering
# Initially schedule pods in parallel, as they won't become ready without successful peering.
podManagementPolicy: Parallel
replicas: 3
selector:
matchLabels:
app: typesense
template:
metadata:
labels:
app: typesense
spec:
securityContext:
fsGroup: 2000
runAsUser: 10000
runAsGroup: 3000
runAsNonRoot: true
terminationGracePeriodSeconds: 300
containers:
- name: typesense
image: typesense/typesense:28.0
ports:
- containerPort: 8107
name: peering
- containerPort: 8108
name: http
env:
- name: TYPESENSE_DATA_DIR
value: /data
- name: TYPESENSE_ANALYTICS_DIR
value: /data/analytics
- name: TYPESENSE_ENABLE_SEARCH_ANALYTICS
value: "TRUE"
- name: TYPESENSE_ANALYTICS_FLUSH_INTERVAL
value: "60"
- name: TYPESENSE_API_KEY
value: "unused"
- name: TYPESENSE_PEERING_ADDRESS
valueFrom:
fieldRef:
fieldPath: status.podIP
- name: TYPESENSE_NODES
value: /nodes
# Re-read DNS for new peer IPs when a pod is replaced.
- name: TYPESENSE_RESET_PEERS_ON_ERROR
value: "TRUE"
resources:
requests:
memory: 100Mi
limits:
memory: 6Gi
volumeMounts:
- name: data
mountPath: /data
- name: nodes
mountPath: /nodes
subPath: nodes
livenessProbe:
tcpSocket:
port: 8108
volumes:
- name: nodes
configMap:
name: nodes
volumeClaimTemplates:
- metadata:
name: data
spec:
accessModes:
- ReadWriteOnce
storageClassName: ebs-encrypted
resources:
requests:
storage: 40Gi
---
apiVersion: v1
kind: Service
metadata:
name: typesense-web
spec:
trafficDistribution: PreferClose
selector:
app: typesense
ports:
- name: http
port: 8108
targetPort: 8108
---
apiVersion: v1
kind: Service
metadata:
name: typesense-peering
spec:
selector:
app: typesense
type: ClusterIP
clusterIP: None
publishNotReadyAddresses: true
ports:
- name: peering
port: 8107
targetPort: 8107
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment