You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: charts/meilisearch/README.md
+109Lines changed: 109 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -50,6 +50,115 @@ For production deployment, the `environment.MEILI_MASTER_KEY` is required. If `M
50
50
51
51
You can also use `auth.existingMasterKeySecret` to use an existing secret that has the key `MEILI_MASTER_KEY`
52
52
53
+
## Horizontal Scaling with Sharding
54
+
55
+
This chart supports Meilisearch's sharding feature for horizontal scaling across multiple replicas. Sharding is available exclusively in **Meilisearch Enterprise Edition v1.19+**.
56
+
57
+
### Prerequisites
58
+
59
+
1.**Meilisearch Enterprise Edition**: Version 1.19 or higher
60
+
2.**License**: Required for production use (free for non-production environments under Business Source License 1.1)
61
+
3.**Master Key**: All instances must share the same `MEILI_MASTER_KEY`
62
+
4.**Primary Key**: Indexes must have a `primaryKey` configured before adding documents
63
+
64
+
### Enabling Sharding
65
+
66
+
To enable sharding in your Helm deployment:
67
+
68
+
```yaml
69
+
sharding:
70
+
enabled: true
71
+
replicaCount: 3# Number of nodes in the sharded cluster
72
+
network:
73
+
experimentalFeatures: true
74
+
auth:
75
+
# Option 1: Let Helm generate random API keys (development)
76
+
searchApiKey: ""
77
+
writeApiKey: ""
78
+
79
+
# Option 2: Use existing secret (recommended for production)
80
+
existingSecret: "my-sharding-keys-secret"
81
+
# The secret should contain 'searchApiKey' and 'writeApiKey' keys by default
82
+
83
+
# If your existing secret uses different key names:
84
+
existingSecretSearchApiKey: "customSearchKeyName"
85
+
existingSecretWriteApiKey: "customWriteKeyName"
86
+
87
+
persistence:
88
+
enabled: true
89
+
storageClass: "standard"
90
+
size: 10Gi
91
+
```
92
+
93
+
### How It Works
94
+
95
+
When sharding is enabled:
96
+
97
+
1. A **headless service** is created for StatefulSet pod-to-pod communication
98
+
2. Each pod gets a unique **persistent volume** for its data partition
99
+
3. A **network configurator sidecar** automatically configures the network topology
100
+
4. Documents sent to any node are automatically distributed across all shards
101
+
5. Each node indexes only its assigned subset of documents using consistent hashing
102
+
103
+
### Searching Sharded Indexes
104
+
105
+
To search across a sharded index, use [Meilisearch federated search](https://www.meilisearch.com/docs/learn/multi_search/performing_federated_search):
106
+
107
+
```bash
108
+
curl -X POST 'http://meilisearch:7700/multi-search' \
109
+
-H 'Authorization: Bearer YOUR_API_KEY' \
110
+
-H 'Content-Type: application/json' \
111
+
-d '{
112
+
"federation": {},
113
+
"queries": [
114
+
{
115
+
"indexUid": "movies",
116
+
"q": "star wars",
117
+
"federationOptions": { "remote": "node-0" }
118
+
},
119
+
{
120
+
"indexUid": "movies",
121
+
"q": "star wars",
122
+
"federationOptions": { "remote": "node-1" }
123
+
},
124
+
{
125
+
"indexUid": "movies",
126
+
"q": "star wars",
127
+
"federationOptions": { "remote": "node-2" }
128
+
}
129
+
]
130
+
}'
131
+
```
132
+
133
+
### Architecture
134
+
135
+
```
136
+
┌─────────────────────────────────────────┐
137
+
│ Load Balancer / Ingress │
138
+
└────────────────┬────────────────────────┘
139
+
│
140
+
┌──────────┼──────────┐
141
+
▼ ▼ ▼
142
+
┌──────┐ ┌──────┐ ┌──────┐
143
+
│Node-0│ │Node-1│ │Node-2│
144
+
└───┬──┘ └───┬──┘ └───┬──┘
145
+
│ │ │
146
+
┌───▼──┐ ┌───▼──┐ ┌───▼──┐
147
+
│ PVC │ │ PVC │ │ PVC │
148
+
│ 10Gi │ │ 10Gi │ │ 10Gi │
149
+
└──────┘ └──────┘ └──────┘
150
+
```
151
+
152
+
### Important Notes
153
+
154
+
-**Persistence**: When sharding is enabled with persistence, each pod gets its own PVC (using volumeClaimTemplates)
155
+
-**Scaling**: Changing the number of replicas after initial deployment requires careful data rebalancing
156
+
-**Network Configuration**: Automatically handled by the sidecar container
157
+
-**API Keys**: The `searchApiKey` and `writeApiKey` are used for secure inter-node communication
158
+
-**Experimental**: Sharding is an experimental feature as of Meilisearch v1.19
159
+
160
+
For more information, see the [official Meilisearch sharding documentation](https://www.meilisearch.com/blog/horizontal-scaling-with-sharding).
replicas: {{ if .Values.sharding.enabled }}{{ .Values.sharding.replicaCount }}{{ else }}{{ .Values.replicaCount | default 1 }}{{ end }}
9
+
serviceName: {{ if .Values.sharding.enabled }}{{ template "meilisearch.fullname" . }}-headless{{ else }}{{ template "meilisearch.fullname" . }}{{ end }}
10
10
selector:
11
11
matchLabels:
12
12
{{- include "meilisearch.selectorLabels" . | nindent 6 }}
@@ -39,19 +39,27 @@ spec:
39
39
- name: tmp
40
40
emptyDir: {}
41
41
{{- if .Values.persistence.enabled }}
42
+
{{- if not .Values.sharding.enabled }}
42
43
- name: {{ .Values.persistence.volume.name }}
43
44
persistentVolumeClaim:
44
45
claimName: {{ if .Values.persistence.existingClaim }}{{ .Values.persistence.existingClaim }}{{- else }}{{ include "meilisearch.fullname" . }}{{- end }}
46
+
{{- end }}
45
47
{{- else }}
46
48
- name: {{ .Values.persistence.volume.name }}
47
49
emptyDir: {}
48
50
{{- end }}
51
+
{{- if .Values.sharding.enabled }}
52
+
- name: network-config
53
+
configMap:
54
+
name: {{ include "meilisearch.fullname" . }}-network-config
name: {{ if .Values.sharding.network.auth.existingSecret }}{{ .Values.sharding.network.auth.existingSecret }}{{ else }}{{ include "meilisearch.fullname" . }}-sharding-keys{{ end }}
161
+
key: {{ if .Values.sharding.network.auth.existingSecretSearchApiKey }}{{ .Values.sharding.network.auth.existingSecretSearchApiKey }}{{ else }}searchApiKey{{ end }}
162
+
- name: WRITE_API_KEY
163
+
valueFrom:
164
+
secretKeyRef:
165
+
name: {{ if .Values.sharding.network.auth.existingSecret }}{{ .Values.sharding.network.auth.existingSecret }}{{ else }}{{ include "meilisearch.fullname" . }}-sharding-keys{{ end }}
166
+
key: {{ if .Values.sharding.network.auth.existingSecretWriteApiKey }}{{ .Values.sharding.network.auth.existingSecretWriteApiKey }}{{ else }}writeApiKey{{ end }}
167
+
volumeMounts:
168
+
- name: network-config
169
+
mountPath: /scripts
170
+
securityContext:
171
+
runAsNonRoot: true
172
+
runAsUser: 100
173
+
capabilities:
174
+
drop:
175
+
- ALL
176
+
allowPrivilegeEscalation: false
177
+
readOnlyRootFilesystem: true
178
+
{{- end }}
114
179
{{- if .Values.containers }}
115
180
{{ toYaml .Values.containers | nindent 8 }}
116
181
{{- end }}
@@ -126,3 +191,25 @@ spec:
126
191
tolerations:
127
192
{{ toYaml . | indent 8 }}
128
193
{{- end }}
194
+
{{- if and .Values.sharding.enabled .Values.persistence.enabled }}
195
+
volumeClaimTemplates:
196
+
- metadata:
197
+
name: {{ .Values.persistence.volume.name }}
198
+
{{- with .Values.persistence.annotations }}
199
+
annotations:
200
+
{{- toYaml . | nindent 10 }}
201
+
{{- end }}
202
+
spec:
203
+
accessModes:
204
+
- {{ .Values.persistence.accessMode | quote }}
205
+
{{- if .Values.persistence.storageClass }}
206
+
{{- if (eq "-" .Values.persistence.storageClass) }}
0 commit comments