Skip to content

Commit 9c703ed

Browse files
Merge #93
93: Allow an existing secret to be used r=alallema a=adinhodovic # Pull Request ## What does this PR do? Adds the functionality to specify an existing secret that has the MEILI_MASTER_KEY defined. ## PR checklist Please check if your PR fulfills the following requirements: - [ ] Does this PR fix an existing issue? - [x] Have you read the contributing guidelines? - [x] Have you made sure that the title is accurate and descriptive of the changes? Thank you so much for contributing to MeiliSearch! Co-authored-by: Adin Hodovic <[email protected]>
2 parents 9551441 + 796b10a commit 9c703ed

File tree

5 files changed

+20
-7
lines changed

5 files changed

+20
-7
lines changed

charts/meilisearch/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v1
22
appVersion: "v0.24.0"
33
description: A Helm chart for the Meilisearch search engine
44
name: meilisearch
5-
version: 0.1.21
5+
version: 0.1.22
66
icon: https://res.cloudinary.com/meilisearch/image/upload/v1597822872/Logo/logo_img.svg
77
home: https://github.com/meilisearch/meilisearch-kubernetes/charts
88
maintainers:

charts/meilisearch/README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ This command deploys MeiliSearch on your Kubernetes cluster using the default co
3131

3232
## Uninstalling the Chart
3333

34-
To uninstall/delete the MeiliSearch` deployment:
34+
To uninstall/delete the `MeiliSearch` deployment:
3535

3636
```bash
3737
# Replace <your-instance-name> with the name of your deployed service
@@ -52,6 +52,8 @@ helm uninstall <your-service-name>
5252
| | |
5353
| `environment.MEILI_NO_ANALYTICS` | Deactivates analytics | `true`
5454
| | |
55+
| `auth.existingMasterKeySecret` | Uses an existing secret that has the MEILI_MASTER_KEY set | `nil`
56+
| | |
5557
| `image.repository` | MeiliSearch image name | `getmeili/meilisearch`
5658
| | |
5759
| `image.tag` | MeiliSearch image tag | `{TAG_NAME}`
@@ -100,4 +102,4 @@ helm uninstall <your-service-name>
100102

101103
The `environment` block allows to specify all the environment variables declared on [MeiliSearch Configuration](https://docs.meilisearch.com/guides/advanced_guides/configuration.html#passing-arguments-via-the-command-line)
102104

103-
For production deployment, the `environment.MEILI_MASTER_KEY` is required. If `MEILI_ENV` is set to "production" without setting `environment.MEILI_MASTER_KEY`, then this chart will automatically create a secure `environment.MEILI_MASTER_KEY` as a secret. To get the value of this secret, you can read it with this command: `kubectl get secret meilisearch-master-key --template={{.data.MEILI_MASTER_KEY}} | base64 --decode`.
105+
For production deployment, the `environment.MEILI_MASTER_KEY` is required. If `MEILI_ENV` is set to "production" without setting `environment.MEILI_MASTER_KEY`, then this chart will automatically create a secure `environment.MEILI_MASTER_KEY` as a secret. To get the value of this secret, you can read it with this command: `kubectl get secret meilisearch-master-key --template={{.data.MEILI_MASTER_KEY}} | base64 --decode`. You can also use `auth.existingMasterKeySecret` to use an existing secret that has the key `MEILI_MASTER_KEY`

charts/meilisearch/templates/_helpers.tpl

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,17 @@ Create chart name and version as used by the chart label.
3535
Checks for environment being set to "production" without a master key being set explicitly
3636
*/}}
3737
{{- define "isProductionWithoutMasterKey" -}}
38-
{{- if and (eq .Values.environment.MEILI_ENV "production") (not .Values.environment.MEILI_MASTER_KEY) -}}
38+
{{- if and (eq .Values.environment.MEILI_ENV "production") (not .Values.environment.MEILI_MASTER_KEY) (not .Values.auth.existingMasterKeySecret) -}}
3939
{{- "true" -}}
4040
{{- else -}}
4141
{{- "false" -}}
4242
{{- end -}}
43-
{{- end -}}
43+
{{- end -}}
44+
45+
{{- define "secretMasterKeyName" -}}
46+
{{- if .Values.auth.existingMasterKeySecret -}}
47+
{{- printf "%s" (tpl .Values.auth.existingMasterKeySecret $) -}}
48+
{{- else -}}
49+
{{- printf "%s-master-key" (include "meilisearch.fullname" .) -}}
50+
{{- end -}}
51+
{{- end -}}

charts/meilisearch/templates/statefulset.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,9 @@ spec:
5353
envFrom:
5454
- configMapRef:
5555
name: {{ template "meilisearch.fullname" . }}-environment
56-
{{- if eq (include "isProductionWithoutMasterKey" .) "true" }}
56+
{{- if or (eq (include "isProductionWithoutMasterKey" .) "true") .Values.auth.existingMasterKeySecret }}
5757
- secretRef:
58-
name: {{ template "meilisearch.fullname" . }}-master-key
58+
name: {{ template "secretMasterKeyName" . }}
5959
{{- end }}
6060
ports:
6161
- name: http

charts/meilisearch/values.yaml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,9 @@ environment:
2929
# chart will automatically create a secure MEILI_MASTER_KEY and push it as a
3030
# secret. Otherwise the below value of MEILI_MASTER_KEY will be used instead.
3131
# MEILI_MASTER_KEY:
32+
auth:
33+
# Use an existing Kubernetes secret for the MEILI_MASTER_KEY
34+
existingMasterKeySecret: ""
3235

3336
serviceAccount:
3437
annotations: {}

0 commit comments

Comments
 (0)