Skip to content

Commit

Permalink
Fix query service env vars handling for additionalEnvs (closes #578) (#…
Browse files Browse the repository at this point in the history
…591)

This PR addresses the issue where the handling of additional environment variables (additionalEnvs) in the query service was not flexible enough.
The changes allow for both backward-compatible key-value pairs and more advanced configurations, including value references from secrets and config maps.

Changes made:
- Updated statefulset.yaml to handle different structures for additionalEnvs.
- Modified values.yaml to include examples for both types of configurations.

Closes #578.
  • Loading branch information
TheShubhendra authored Jan 6, 2025
1 parent 1acdbc2 commit ecf3b59
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 6 deletions.
2 changes: 1 addition & 1 deletion charts/signoz/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: signoz
version: 0.64.1
version: 0.64.2
appVersion: "0.66.0"
description: SigNoz Observability Platform Helm Chart
type: application
Expand Down
27 changes: 27 additions & 0 deletions charts/signoz/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -740,3 +740,30 @@ imagePullSecrets:
{{- end }}
{{- end }}
{{- end }}
{{/*
Function to render environment variables
*/}}
{{- define "signoz.renderAdditionalEnv" -}}
{{- $dict := . -}}
{{- $processedKeys := dict -}}
{{- range keys . | sortAlpha }}
{{- $val := pluck . $dict | first -}}
{{- $key := upper . -}}
{{- if not (hasKey $processedKeys $key) }}
{{- $processedKeys = merge $processedKeys (dict $key true) -}}
{{- $valueType := printf "%T" $val -}}
{{- if eq $valueType "map[string]interface {}" }}
- name: {{ $key }}
{{ toYaml $val | indent 2 -}}
{{- else if eq $valueType "string" }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- else }}
- name: {{ $key }}
value: {{ $val | quote }}
{{- end }}
{{- end -}}
{{- end -}}
{{- end -}}
5 changes: 1 addition & 4 deletions charts/signoz/templates/query-service/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -138,10 +138,7 @@ spec:
value: {{ quote .Values.queryService.configVars.telemetryEnabled }}
- name: DEPLOYMENT_TYPE
value: {{ .Values.queryService.configVars.deploymentType }}
{{- range $key, $val := .Values.queryService.additionalEnvs }}
- name: {{ $key }}
value: {{ $val | toYaml }}
{{- end }}
{{- include "signoz.renderAdditionalEnv" .Values.queryService.additionalEnvs | nindent 12 }}
{{- if .Values.queryService.smtpVars.enabled }}
- name: SMTP_ENABLED
value: "true"
Expand Down
17 changes: 16 additions & 1 deletion charts/signoz/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -596,7 +596,22 @@ queryService:
- --use-trace-new-schema=true
# -- Additional environments to set for queryService
additionalEnvs: {}
# env_key: env_value
# Environment variables for the Query Service.
# You can specify variables in two ways:
# 1. Flexible structure for advanced configurations (recommended):
# Example:
# additionalEnvs:
# MY_KEY:
# value: my-value # Direct value
# SECRET_KEY:
# valueFrom: # Reference from a Secret or ConfigMap
# secretKeyRef:
# name: my-secret
# key: my-key
# 2. Simple key-value pairs (backward-compatible):
# Example:
# additionalEnvs:
# MY_KEY: my-value

initContainers:
init:
Expand Down

0 comments on commit ecf3b59

Please sign in to comment.