Quickstart: Typesense Operator Installation
Requirements
- Typesense Operator v2.0 requires Kubernetes 1.20 or later.
- Works on self-managed and cloud managed clusters
Installation Steps
For an alternative installation method, refer to the TKO Helm Charts.
Set Up Kubernetes Cluster
- Use minikube or any other tool to create your Kubernetes cluster.
Deploy Custom Resource Definition
- Navigate to the deployment directory
cd deploy
- Deploy the Custom Resource Definition
kubectl create -f crd.yaml -n <namespace>
Deploy RBAC (Role-Based Access Control)
- Deploy RBAC configuration:
kubectl create -f rbac.yaml -n <namespace>
Create secret for apikey used by Typesense
- Make sure to deploy the secret in the same namespace as the operator:
- NOTE: do not change key
apikeyas it is used by operator to identify the value.
kubectl create secret generic -n <namespace> typesense-apikey --from-literal=apikey=MWYyZDFlMmU2N2Rm
Deploy the Latest Operator
- Deploy the latest Typesense Operator:
kubectl create -f operator.yaml -n <namespace>
Verify Operator Deployment
- Check if the operator pods are up and running:
kubectl get pods -n <namespace>
Configure Operator
- Once the operator is running, configure it by referring to the configuration section below.
Operator Configuration
- Sample configuration can be found in operator-config.yaml
- All the configuration must be specified under
specorconfig - Supported configurations under
specreplicas: Number of replicas of typesense.- default :
3
NOTE: When the number of replicas are increased the operator automatically handles the peering connection between the replicas.
- default :
namespace: Namespace to be used for deployment.- default :
typesense
- default :
image: Typesense production ready docker image. List can be found here.- default :
latesttag will be pulled
- default :
resources: Resources for cpu and memory.- default
resources: requests: memory: 100Mi cpu: "64m" limits: memory: 256Mi cpu: "512m"
- default
nodeSelector: Node to which pod has to be scheduled. if not specified, it picks up the node with available resourcesstorageClass: Provides a way to administor the storage. Create a storage class with the provider of your choice and add it to the operator config.
Options available arenameandsizename: Name of the storageClass that the operator should consider for volume mount.size: Size of the volume to be allocated to each typesense replica.
NOTE: Supports all k8s Storageclass.
startupProbe: Protect slow starting containers with startup probes
Options available arefailureThresholdandperiodSeconds
NOTE: k8s startupProbe.livenessProbe: Kubernetes provides liveness probes to detect and remedy such situations.
Options available arefailureThresholdandperiodSeconds
NOTE: k8s livenessProbe.
- Supported configurations under
configsecret: Typesense authentication is done using a password which is stored as secret. Provide the name of the secret here.- default : No default value
- default : No default value
env: Support for supplying environment variables to Typesense. Refer here.
NOTE: Specifying these env will either add or override existing variables.- default : No default value
- default : No default value
-
Deploying the configuration
- Create the operator
kubectl create -f operator-config.yaml - To apply any changes made to the config
kubectl apply -f operator-config.yamlMonitor Cluster Creation
- Create the operator
-
Monitor the creation of the Typesense cluster by checking pod statuses:
kubectl get pods -n <namespace>
Operator metrics
- Operator exposes the following Prometheus metrics to periodically poll this endpoint and export the data into Prometheus
| Metrics | Description |
| tok_resource_create_success_total | Total number of successful resource creation events by the operator |
| tok_resource_update_success_total | Total number of updates to the resource by the operator |
| tok_resource_delete_success_total | Total number of deletion events by the operator |
| tok_version_info | Idicates the operator version that is currently deployed |
Upgrade
- Before performing this upgrade process, it is recommended to
- Test it out in a
devenvironment - Backup the Typesense data
- Test it out in a
- The process of updating TKO is simple
- Watch for changes in the CRD file and apply those changes
- Watch for changes in the RBAC file and apply those changes
- Apply the new operator.yaml file
- Once the new operator pod is up and running, re-apply the configuration of the your operator so that the changes (if any) are reflected.
kubectl apply -f <your operator config file yaml>
Cleanup
- When you want to fully remove the cluster operator and associated definitions, you can run
kubectl delete -f operator-config.yaml
kubectl delete -f deploy/crd.yaml
kubectl delete -f deploy/operator.yaml
kubectl delete -f deploy/rbac.yaml