-
Notifications
You must be signed in to change notification settings - Fork 161
feat(qdrant): add TLS support via cert-manager #2685
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
be1b1a8
860bf3b
8e7dc66
bc25a7d
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,78 @@ | ||
| {{- $clusterDomain := "cozy.local" }} | ||
| {{- if .Values._cluster }} | ||
| {{- $clusterDomain = (index .Values._cluster "cluster-domain") | default "cozy.local" }} | ||
| {{- end }} | ||
| {{- $tlsMap := default (dict) .Values.tls -}} | ||
| {{- $tlsEnabled := false -}} | ||
| {{- if hasKey $tlsMap "enabled" -}} | ||
| {{- $tlsEnabled = index $tlsMap "enabled" -}} | ||
| {{- else -}} | ||
| {{- $tlsEnabled = .Values.external | default false -}} | ||
| {{- end -}} | ||
| {{- if $tlsEnabled }} | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Issuer | ||
| metadata: | ||
| name: {{ .Release.Name }}-selfsigned | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| selfSigned: {} | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: {{ .Release.Name }}-ca | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| secretName: {{ .Release.Name }}-ca | ||
| duration: 43800h | ||
| commonName: {{ .Release.Name }}-ca | ||
| issuerRef: | ||
| name: {{ .Release.Name }}-selfsigned | ||
| isCA: true | ||
| privateKey: | ||
| rotationPolicy: Never | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Issuer | ||
| metadata: | ||
| name: {{ .Release.Name }}-ca | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| ca: | ||
| secretName: {{ .Release.Name }}-ca | ||
| --- | ||
| apiVersion: cert-manager.io/v1 | ||
| kind: Certificate | ||
| metadata: | ||
| name: {{ .Release.Name }}-tls | ||
| namespace: {{ .Release.Namespace }} | ||
| spec: | ||
| secretName: {{ .Release.Name }}-tls | ||
| duration: 8760h | ||
| renewBefore: 720h | ||
| isCA: false | ||
| issuerRef: | ||
| name: {{ .Release.Name }}-ca | ||
| commonName: {{ .Release.Name }} | ||
| # server auth: required for REST (6333) and gRPC (6334) TLS endpoints. | ||
| # client auth: required for p2p mTLS — Qdrant uses ca_cert for peer | ||
| # verification when cluster.p2p.enable_tls is true (see qdrant.yaml). | ||
| usages: | ||
| - digital signature | ||
| - key encipherment | ||
| - server auth | ||
| - client auth | ||
| dnsNames: | ||
| - {{ .Release.Name }} | ||
| - {{ .Release.Name }}.{{ .Release.Namespace }}.svc | ||
| - {{ .Release.Name }}.{{ .Release.Namespace }}.svc.{{ $clusterDomain }} | ||
| - {{ .Release.Name }}-headless | ||
| - {{ .Release.Name }}-headless.{{ .Release.Namespace }}.svc | ||
| - {{ .Release.Name }}-headless.{{ .Release.Namespace }}.svc.{{ $clusterDomain }} | ||
| - "*.{{ .Release.Name }}-headless.{{ .Release.Namespace }}.svc.{{ $clusterDomain }}" | ||
| {{- if .Values.external }} | ||
| - {{ .Release.Name }}.{{ .Values._namespace.host }} | ||
| {{- end }} | ||
| {{- end }} |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,3 +1,10 @@ | ||||||||||||||||||||||||||||||||
| {{- $tlsMap := default (dict) .Values.tls -}} | ||||||||||||||||||||||||||||||||
| {{- $tlsEnabled := false -}} | ||||||||||||||||||||||||||||||||
| {{- if hasKey $tlsMap "enabled" -}} | ||||||||||||||||||||||||||||||||
| {{- $tlsEnabled = index $tlsMap "enabled" -}} | ||||||||||||||||||||||||||||||||
| {{- else -}} | ||||||||||||||||||||||||||||||||
| {{- $tlsEnabled = .Values.external | default false -}} | ||||||||||||||||||||||||||||||||
| {{- end -}} | ||||||||||||||||||||||||||||||||
|
Comment on lines
+1
to
+7
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🧩 Analysis chain🏁 Script executed: #!/bin/bash
set -euo pipefail
cd packages/apps/qdrant
cat > /tmp/qdrant-values-null.yaml <<'YAML'
external: true
tls:
enabled: null
YAML
# Verify rendered value under null is inherited from external (expected: true)
helm template test-qdrant . -f /tmp/qdrant-values-null.yaml --show-only templates/qdrant.yaml \
| rg -n -C2 'enable_tls|additionalVolumes|additionalVolumeMounts'Repository: cozystack/cozystack Length of output: 107 🏁 Script executed: # First, examine the qdrant template file
cd packages/apps/qdrant
find . -name "qdrant.yaml" -type fRepository: cozystack/cozystack Length of output: 87 🏁 Script executed: # Read the qdrant template file with line numbers
cat -n packages/apps/qdrant/templates/qdrant.yamlRepository: cozystack/cozystack Length of output: 2571 🏁 Script executed: # Check the values structure in this chart
ls -la packages/apps/qdrant/
cat packages/apps/qdrant/values.yaml | head -50Repository: cozystack/cozystack Length of output: 1904 🏁 Script executed: # Check the values.yaml to see default tls structure
cat packages/apps/qdrant/values.yamlRepository: cozystack/cozystack Length of output: 2415 🏁 Script executed: # Look for values.schema.json to understand the expected types
cat packages/apps/qdrant/values.schema.jsonRepository: cozystack/cozystack Length of output: 3741 🌐 Web query:
💡 Result: In Helm templates (Go text/template), a value that is actually nil (“null” in YAML/values) does not reliably render as the literal string "null". Instead, Go/Helm ends up rendering a blank string (sometimes as a single space) when nil is expanded to text. This is why you may see YAML lines like Citations:
Handle The values schema documents a tri-state contract: Suggested fix {{- $tlsMap := default (dict) .Values.tls -}}
{{- $tlsEnabled := false -}}
-{{- if hasKey $tlsMap "enabled" -}}
- {{- $tlsEnabled = index $tlsMap "enabled" -}}
-{{- else -}}
+{{- $tlsRaw := index $tlsMap "enabled" -}}
+{{- if and (hasKey $tlsMap "enabled") (ne $tlsRaw nil) -}}
+ {{- $tlsEnabled = $tlsRaw -}}
+{{- else -}}
{{- $tlsEnabled = .Values.external | default false -}}
{{- end -}}📝 Committable suggestion
Suggested change
🧰 Tools🪛 YAMLlint (1.38.0)[error] 1-1: syntax error: expected the node content, but found '-' (syntax) 🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||
| apiVersion: helm.toolkit.fluxcd.io/v2 | ||||||||||||||||||||||||||||||||
| kind: HelmRelease | ||||||||||||||||||||||||||||||||
| metadata: | ||||||||||||||||||||||||||||||||
|
|
@@ -41,3 +48,28 @@ spec: | |||||||||||||||||||||||||||||||
| service: | ||||||||||||||||||||||||||||||||
| type: LoadBalancer | ||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||
| config: | ||||||||||||||||||||||||||||||||
| service: | ||||||||||||||||||||||||||||||||
| enable_tls: {{ $tlsEnabled }} | ||||||||||||||||||||||||||||||||
| cluster: | ||||||||||||||||||||||||||||||||
| p2p: | ||||||||||||||||||||||||||||||||
| enable_tls: {{ $tlsEnabled }} | ||||||||||||||||||||||||||||||||
| {{- if $tlsEnabled }} | ||||||||||||||||||||||||||||||||
| tls: | ||||||||||||||||||||||||||||||||
| cert: /qdrant/tls/tls.crt | ||||||||||||||||||||||||||||||||
| key: /qdrant/tls/tls.key | ||||||||||||||||||||||||||||||||
| ca_cert: /qdrant/tls/ca.crt | ||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||
| {{- if $tlsEnabled }} | ||||||||||||||||||||||||||||||||
| additionalVolumes: | ||||||||||||||||||||||||||||||||
| - name: tls | ||||||||||||||||||||||||||||||||
| secret: | ||||||||||||||||||||||||||||||||
| secretName: {{ .Release.Name }}-tls | ||||||||||||||||||||||||||||||||
| additionalVolumeMounts: | ||||||||||||||||||||||||||||||||
| - name: tls | ||||||||||||||||||||||||||||||||
| mountPath: /qdrant/tls | ||||||||||||||||||||||||||||||||
| readOnly: true | ||||||||||||||||||||||||||||||||
| {{- else }} | ||||||||||||||||||||||||||||||||
| additionalVolumes: [] | ||||||||||||||||||||||||||||||||
| additionalVolumeMounts: [] | ||||||||||||||||||||||||||||||||
| {{- end }} | ||||||||||||||||||||||||||||||||
|
Comment on lines
+63
to
+75
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This {{- if $tlsEnabled }}
additionalVolumes:
- name: tls
secret:
secretName: {{ .Release.Name }}-tls
additionalVolumeMounts:
- name: tls
mountPath: /qdrant/tls
readOnly: true
{{- end }} |
||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This logic to determine if TLS is enabled is also present in
templates/certmanager.yaml. To improve maintainability and adhere to the DRY (Don't Repeat Yourself) principle, this logic should be extracted into a common helper template.You can create a new file
packages/apps/qdrant/templates/_helpers.tplwith the following content:Then, you can replace this block (and the similar one in
certmanager.yaml) with a single line: