From c29e039d71999b5f1a3964b028d9a41cd12f08ef Mon Sep 17 00:00:00 2001 From: "Ehsan.Asadi" Date: Tue, 30 Dec 2025 16:34:13 +0330 Subject: [PATCH] feat(helm): add environment variables for Reflex configuration Changes: - Add API_URL, FRONTEND_PORT, BACKEND_PORT env vars to deployment - Construct DATABASE_URL from PostgreSQL connection params - Construct REDIS_URL from Redis connection params (with/without password) - Add reflex.apiUrl config to values files: * Default: http://localhost:8000 * Staging: https://staging.peikarband.ir * Production: https://peikarband.ir - Add ENVIRONMENT to configMap This ensures rxconfig.py gets proper environment-specific configuration without hardcoding values. The app now works correctly in all environments (dev, staging, production) with appropriate URLs and settings. --- helm/peikarband/templates/deployment.yaml | 19 +++++++++++++++++++ helm/peikarband/values-production.yaml | 4 ++++ helm/peikarband/values-staging.yaml | 4 ++++ helm/peikarband/values.yaml | 5 +++++ 4 files changed, 32 insertions(+) diff --git a/helm/peikarband/templates/deployment.yaml b/helm/peikarband/templates/deployment.yaml index 433b0ee..6b2497e 100644 --- a/helm/peikarband/templates/deployment.yaml +++ b/helm/peikarband/templates/deployment.yaml @@ -49,6 +49,13 @@ spec: {{- toYaml .Values.resources | nindent 12 }} env: {{- toYaml .Values.env | nindent 12 }} + # Reflex configuration + - name: API_URL + value: {{ .Values.reflex.apiUrl | quote }} + - name: FRONTEND_PORT + value: {{ .Values.service.frontend.targetPort | quote }} + - name: BACKEND_PORT + value: {{ .Values.service.backend.targetPort | quote }} {{- if .Values.postgresql.enabled }} - name: DATABASE_HOST value: {{ .Values.postgresql.external.host }} @@ -66,17 +73,29 @@ spec: secretKeyRef: name: {{ .Values.postgresql.external.passwordSecret.name }} key: {{ .Values.postgresql.external.passwordSecret.key }} + # Construct DATABASE_URL for Reflex + - name: DATABASE_URL + value: "postgresql://$(DATABASE_USER):$(DATABASE_PASSWORD)@$(DATABASE_HOST):$(DATABASE_PORT)/$(DATABASE_NAME)" {{- end }} {{- if .Values.redis.enabled }} - name: REDIS_HOST value: {{ .Values.redis.external.host }} - name: REDIS_PORT value: {{ .Values.redis.external.port | quote }} + {{- if .Values.redis.external.passwordSecret }} - name: REDIS_PASSWORD valueFrom: secretKeyRef: name: {{ .Values.redis.external.passwordSecret.name }} key: {{ .Values.redis.external.passwordSecret.key }} + # Construct REDIS_URL with password + - name: REDIS_URL + value: "redis://:$(REDIS_PASSWORD)@$(REDIS_HOST):$(REDIS_PORT)/0" + {{- else }} + # Construct REDIS_URL without password + - name: REDIS_URL + value: "redis://$(REDIS_HOST):$(REDIS_PORT)/0" + {{- end }} {{- end }} envFrom: - configMapRef: diff --git a/helm/peikarband/values-production.yaml b/helm/peikarband/values-production.yaml index ef512e7..6b1e0e6 100644 --- a/helm/peikarband/values-production.yaml +++ b/helm/peikarband/values-production.yaml @@ -6,6 +6,10 @@ replicaCount: 3 image: pullPolicy: Always +# Reflex configuration for production +reflex: + apiUrl: "https://peikarband.ir" # Production API URL + podAnnotations: prometheus.io/scrape: "true" prometheus.io/port: "8000" diff --git a/helm/peikarband/values-staging.yaml b/helm/peikarband/values-staging.yaml index 39dab99..6a4fe3c 100644 --- a/helm/peikarband/values-staging.yaml +++ b/helm/peikarband/values-staging.yaml @@ -5,6 +5,10 @@ replicaCount: 1 image: pullPolicy: Always +# Reflex configuration for staging +reflex: + apiUrl: "https://staging.peikarband.ir" # Staging API URL + resources: limits: cpu: 500m diff --git a/helm/peikarband/values.yaml b/helm/peikarband/values.yaml index 570b10a..dfb53da 100644 --- a/helm/peikarband/values.yaml +++ b/helm/peikarband/values.yaml @@ -124,10 +124,15 @@ env: envFrom: [] +# Reflex-specific configuration +reflex: + apiUrl: "http://localhost:8000" # Override in production values + configMap: data: APP_NAME: "peikarband" LOG_LEVEL: "info" + ENVIRONMENT: "production" secretRef: name: "peikarband-secrets"