Skip to content

Add support for built-in TLS#316

Open
Sigurs wants to merge 2 commits into
meilisearch:mainfrom
Sigurs:main
Open

Add support for built-in TLS#316
Sigurs wants to merge 2 commits into
meilisearch:mainfrom
Sigurs:main

Conversation

@Sigurs
Copy link
Copy Markdown

@Sigurs Sigurs commented Mar 26, 2026

Pull Request

Related issue

Fixes #315

What does this PR do?

Adds support to configure built-in TLS via the Helm chart while still leaving room for possible future implementations of certificate generation.

Simplest possible configuration - also used to test this:

tls:
  enabled: true
  existingSecret: meilisearch-tls

Not my first time working on Helm charts, but AI was used to do quick edits around the templates and to speed up my work.
Looks like helm-docs hadn't been ran in a while.

PR checklist

Please check if your PR fulfills the following requirements:

  • Did you use any AI tool while implementing this PR (code, tests, docs, etc.)? If yes, disclose it in the PR description and describe what it was used for. AI usage is allowed when it is disclosed.
  • Does this PR fix an existing issue, or have you listed the changes applied in the PR description (and why they are needed)?
  • Have you read the contributing guidelines?
  • Have you made sure that the title is accurate and descriptive of the changes?

Thank you so much for contributing to Meilisearch!

Summary by CodeRabbit

  • New Features

    • TLS/HTTPS support for the server and Prometheus scraping, including optional OCSP, session resumption, and ticket controls; certificate mounting and related env vars
    • Added probe (liveness/readiness/startup) fields, initContainers, and scheduling (priorityClassName) options
    • ServiceMonitor TLS and HTTPS endpoint support; test probe commands respect TLS
  • Chores

    • Bumped Helm chart and image versions; adjusted default storageClass and removed documented image.digest and replicaCount
    • Added serviceAccount.automountServiceAccountToken

@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

Bumped Meilisearch Helm chart to 0.30.0 and added built-in TLS support: new tls.* values, certificate/OCSP secret volumes and mounts, TLS-aware env vars and HTTPS probes in the StatefulSet, ServiceMonitor TLS scraping support, updated docs, and manifest checksum update.

Changes

Cohort / File(s) Summary
Chart metadata
charts/meilisearch/Chart.yaml
Chart version bumped from 0.29.0 to 0.30.0.
Values & defaults
charts/meilisearch/values.yaml, charts/meilisearch/README.md
Added tls.* block (enable, existingSecret, mountPath, cert/key filenames, resumption, tickets, optional OCSP secret/filename) and serviceMonitor.tlsConfig; updated documented defaults (appVersion, image.tag, removed image.digest, probe fields, initContainers, priorityClassName, persistence.storageClass change, serviceAccount.automountServiceAccountToken, ServiceMonitor namespace/tlsConfig).
StatefulSet template
charts/meilisearch/templates/statefulset.yaml
Fail installation if TLS enabled without tls.existingSecret; add tls-certs (and optional tls-ocsp) secret volumes/mounts; inject MEILI_SSL_* env vars; set probe scheme: HTTPS when TLS enabled.
ServiceMonitor template
charts/meilisearch/templates/serviceMonitor.yaml
When TLS enabled, set scheme: https and optionally emit tlsConfig from serviceMonitor.tlsConfig; otherwise retain HTTP endpoints.
Test Pod / manifests
charts/meilisearch/templates/tests/test-connection.yaml, manifests/meilisearch.yaml
Adjusted test wget args to structured list and conditionally use https:// plus --no-check-certificate when TLS enabled; updated checksum/config annotation in manifest.

Sequence Diagram(s)

sequenceDiagram
    participant Client as Client
    participant Service as K8s Service
    participant Pod as Meilisearch Pod
    participant Secret as TLS Secret
    participant Prom as Prometheus (ServiceMonitor)

    Client->>Service: HTTPS request
    Service->>Pod: Forward to container port (HTTPS)
    Pod->>Secret: Mount cert/key at tls.mountPath
    Note over Pod: MEILI_SSL_CERT_PATH / MEILI_SSL_KEY_PATH env vars set
    Prom->>Service: Scrape endpoint (ServiceMonitor)
    alt TLS enabled
      Prom->>Pod: HTTPS scrape using tlsConfig
    else TLS disabled
      Prom->>Pod: HTTP scrape
    end
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 With secret mounts and TLS so neat,

I hop and bind the certs on fleet.
Probes now call with HTTPS cheer,
Prom scrapes safely, far and near.
Hoppity-hop — secure search is here!

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'Add support for built-in TLS' is concise and clearly summarizes the main change of adding TLS configuration support to the Helm chart.
Linked Issues check ✅ Passed The PR implements all requirements from issue #315: enables TLS configuration via Helm chart, supports externally provided certificates through existingSecret, allows TLS termination at Meilisearch, and provides comprehensive Helm configuration.
Out of Scope Changes check ✅ Passed All changes are in-scope: TLS support in chart templates, values, ServiceMonitor TLS config, test updates, and documentation align with issue #315 objectives of adding built-in TLS support.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/meilisearch/templates/statefulset.yaml`:
- Around line 55-60: The OCSP secret mount is currently gated only on
.Values.tls.existingOcspSecret, so pods will mount tls-ocsp even when TLS is
disabled; update the template conditional to require both TLS is enabled and the
secret exists (i.e., check .Values.tls.enabled &&
.Values.tls.existingOcspSecret) where the tls-ocsp volume and the corresponding
volumeMounts are declared (the blocks referring to tls-ocsp and the secretName
using .Values.tls.existingOcspSecret), and make the same change for the other
occurrence (the second mount block around the volumeMounts section) so the OCSP
secret is only used when TLS is enabled.
- Around line 104-122: Update the Helm test hook in manifests/meilisearch.yaml
so it uses HTTPS and matches tls.enabled behavior: change the wget curl
invocation(s) (the test hook lines around the existing "wget meilisearch:7700")
to call the HTTPS URL (e.g. https://meilisearch:7700/) and handle certificate
verification consistently with the chart (either add
--no-check-certificate/--insecure or, preferably, point the client to the TLS
CA/cert mounted by the chart), and gate the change behind the same
.Values.tls.enabled conditional used in the StatefulSet so the test switches to
HTTPS only when TLS is enabled.
- Around line 49-53: When tls.enabled is true the template must fail if
tls.existingSecret is not provided; update the StatefulSet template
(statefulset.yaml) to use Helm's required function for
.Values.tls.existingSecret inside the conditional so the chart errors fast
instead of rendering an invalid secretName. For example, replace the raw
secretName reference with a required(...) call that includes a clear message
like "tls.existingSecret is required when tls.enabled is true" so Helm will
abort when the value is missing.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 5fc46014-c46e-439c-9b69-b4a51785df93

📥 Commits

Reviewing files that changed from the base of the PR and between 329159e and 39acd20.

📒 Files selected for processing (6)
  • charts/meilisearch/Chart.yaml
  • charts/meilisearch/README.md
  • charts/meilisearch/templates/serviceMonitor.yaml
  • charts/meilisearch/templates/statefulset.yaml
  • charts/meilisearch/values.yaml
  • manifests/meilisearch.yaml

Comment thread charts/meilisearch/templates/statefulset.yaml
Comment thread charts/meilisearch/templates/statefulset.yaml
Comment thread charts/meilisearch/templates/statefulset.yaml
@Sigurs Sigurs marked this pull request as draft March 26, 2026 15:29
@Sigurs Sigurs marked this pull request as ready for review March 26, 2026 15:31
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@charts/meilisearch/README.md`:
- Around line 137-138: Update the README entry for tls.existingSecret to remove
the hardcoded tls.crt/tls.key filenames and instead state that the secret must
contain keys matching tls.certFilename and tls.keyFilename (with defaults
tls.crt and tls.key); specifically edit the description for tls.existingSecret
and mention tls.certFilename and tls.keyFilename so users know the filenames are
configurable and the defaults are tls.crt and tls.key.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e1a8de38-aab4-49d4-97fc-2a44365a724a

📥 Commits

Reviewing files that changed from the base of the PR and between 39acd20 and 1e47343.

📒 Files selected for processing (6)
  • charts/meilisearch/Chart.yaml
  • charts/meilisearch/README.md
  • charts/meilisearch/templates/serviceMonitor.yaml
  • charts/meilisearch/templates/statefulset.yaml
  • charts/meilisearch/values.yaml
  • manifests/meilisearch.yaml
✅ Files skipped from review due to trivial changes (2)
  • charts/meilisearch/Chart.yaml
  • manifests/meilisearch.yaml
🚧 Files skipped from review as they are similar to previous changes (3)
  • charts/meilisearch/templates/serviceMonitor.yaml
  • charts/meilisearch/values.yaml
  • charts/meilisearch/templates/statefulset.yaml

Comment on lines +137 to +138
| tls.existingSecret | string | `""` | Name of existing Kubernetes TLS secret (must contain tls.crt and tls.key) |
| tls.keyFilename | string | `"tls.key"` | Key filename in the secret |
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

tls.existingSecret description conflicts with configurable filename keys

The description at Line 137 hardcodes tls.crt/tls.key, but Line 134 and Line 138 allow custom filenames. Please document this as “must contain keys matching tls.certFilename and tls.keyFilename (defaults: tls.crt, tls.key)” to avoid user misconfiguration.

Suggested doc fix
-| tls.existingSecret | string | `""` | Name of existing Kubernetes TLS secret (must contain tls.crt and tls.key) |
+| tls.existingSecret | string | `""` | Name of existing Kubernetes TLS secret (must contain keys matching tls.certFilename and tls.keyFilename; defaults: tls.crt and tls.key) |
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
| tls.existingSecret | string | `""` | Name of existing Kubernetes TLS secret (must contain tls.crt and tls.key) |
| tls.keyFilename | string | `"tls.key"` | Key filename in the secret |
| tls.existingSecret | string | `""` | Name of existing Kubernetes TLS secret (must contain keys matching tls.certFilename and tls.keyFilename; defaults: tls.crt and tls.key) |
| tls.keyFilename | string | `"tls.key"` | Key filename in the secret |
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/meilisearch/README.md` around lines 137 - 138, Update the README entry
for tls.existingSecret to remove the hardcoded tls.crt/tls.key filenames and
instead state that the secret must contain keys matching tls.certFilename and
tls.keyFilename (with defaults tls.crt and tls.key); specifically edit the
description for tls.existingSecret and mention tls.certFilename and
tls.keyFilename so users know the filenames are configurable and the defaults
are tls.crt and tls.key.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
charts/meilisearch/templates/statefulset.yaml (1)

58-63: ⚠️ Potential issue | 🟠 Major

Gate OCSP secret resources on TLS enablement as well.

Line 58 and Line 89 still mount/render OCSP resources when TLS is disabled. This can create an unnecessary secret dependency for TLS-off installs.

Suggested fix
-        {{- if .Values.tls.existingOcspSecret }}
+        {{- if and .Values.tls.enabled .Values.tls.existingOcspSecret }}
         - name: tls-ocsp
           secret:
             secretName: {{ .Values.tls.existingOcspSecret }}
             defaultMode: 0400
         {{- end }}
...
-            {{- if .Values.tls.existingOcspSecret }}
+            {{- if and .Values.tls.enabled .Values.tls.existingOcspSecret }}
             - name: tls-ocsp
               mountPath: {{ .Values.tls.mountPath }}/ocsp
               readOnly: true
             {{- end }}

Also applies to: 89-93

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@charts/meilisearch/templates/statefulset.yaml` around lines 58 - 63, The OCSP
secret mount is currently only gated by .Values.tls.existingOcspSecret and still
renders when TLS is disabled; update both conditional blocks that reference
tls-ocsp and .Values.tls.existingOcspSecret to require TLS to be enabled as well
(e.g., change the condition to check both .Values.tls.enabled and
.Values.tls.existingOcspSecret) so the tls-ocsp secret is only rendered/mounted
when TLS is enabled; apply this change to the conditional around the tls-ocsp
secret mount and the other OCSP-related block (both occurrences referencing
tls-ocsp and .Values.tls.existingOcspSecret).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Duplicate comments:
In `@charts/meilisearch/templates/statefulset.yaml`:
- Around line 58-63: The OCSP secret mount is currently only gated by
.Values.tls.existingOcspSecret and still renders when TLS is disabled; update
both conditional blocks that reference tls-ocsp and
.Values.tls.existingOcspSecret to require TLS to be enabled as well (e.g.,
change the condition to check both .Values.tls.enabled and
.Values.tls.existingOcspSecret) so the tls-ocsp secret is only rendered/mounted
when TLS is enabled; apply this change to the conditional around the tls-ocsp
secret mount and the other OCSP-related block (both occurrences referencing
tls-ocsp and .Values.tls.existingOcspSecret).

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: 1d1823e4-76d8-4b11-8cd8-e714af485bc2

📥 Commits

Reviewing files that changed from the base of the PR and between 1e47343 and 4e3febd.

📒 Files selected for processing (3)
  • charts/meilisearch/templates/statefulset.yaml
  • charts/meilisearch/templates/tests/test-connection.yaml
  • manifests/meilisearch.yaml
✅ Files skipped from review due to trivial changes (1)
  • manifests/meilisearch.yaml

@curquiza curquiza requested a review from brunoocasali March 30, 2026 16:17
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

Successfully merging this pull request may close these issues.

Support for built-in TLS

1 participant