From 38dea2ec6a510e318543f3d58e779322f931cda9 Mon Sep 17 00:00:00 2001 From: Kim Gustyr Date: Wed, 26 Apr 2023 11:42:01 +0100 Subject: [PATCH] feat: allow for PosgreSQL-based analytics, deprecate the in-chart InfluxDB usage --- charts/flagsmith/Chart.yaml | 4 +-- charts/flagsmith/ci/e2e-test-values.yaml | 8 ++--- charts/flagsmith/ci/influxdb-test-values.yaml | 11 ------- charts/flagsmith/templates/NOTES.txt | 29 +++++++++++++++++++ .../flagsmith/templates/_api_environment.yaml | 22 ++++++-------- charts/flagsmith/values.yaml | 18 +++++++++++- 6 files changed, 60 insertions(+), 32 deletions(-) delete mode 100644 charts/flagsmith/ci/influxdb-test-values.yaml diff --git a/charts/flagsmith/Chart.yaml b/charts/flagsmith/Chart.yaml index 2d7e496..8a3b970 100644 --- a/charts/flagsmith/Chart.yaml +++ b/charts/flagsmith/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: flagsmith description: Flagsmith type: application -version: 0.17.0 -appVersion: 2.42.1 +version: 0.18.0 +appVersion: 2.50.2 dependencies: - name: postgresql repository: https://charts.helm.sh/stable diff --git a/charts/flagsmith/ci/e2e-test-values.yaml b/charts/flagsmith/ci/e2e-test-values.yaml index ea2a7fa..b131a30 100644 --- a/charts/flagsmith/ci/e2e-test-values.yaml +++ b/charts/flagsmith/ci/e2e-test-values.yaml @@ -6,10 +6,8 @@ frontend: SLACK_TOKEN: "${SLACK_TOKEN}" api: + analytics: + enabled: true extraEnv: - EMAIL_BACKEND: 'django.core.mail.backends.console.EmailBackend' + EMAIL_BACKEND: "django.core.mail.backends.console.EmailBackend" FE_E2E_TEST_USER_EMAIL: nightwatch@solidstategroup.com -influxdb2: - # Needed to set this for the tests to not fail. Possibly related to - # https://github.com/Flagsmith/flagsmith/issues/340 - enabled: false diff --git a/charts/flagsmith/ci/influxdb-test-values.yaml b/charts/flagsmith/ci/influxdb-test-values.yaml deleted file mode 100644 index fc2a058..0000000 --- a/charts/flagsmith/ci/influxdb-test-values.yaml +++ /dev/null @@ -1,11 +0,0 @@ -tests: - enabled: true - -api: - extraEnv: - ENABLE_INFLUXDB_FEATURES: 'true' - influxdbSetup: - enabled: true - -influxdb2: - enabled: true diff --git a/charts/flagsmith/templates/NOTES.txt b/charts/flagsmith/templates/NOTES.txt index 35f58f1..633ccf8 100644 --- a/charts/flagsmith/templates/NOTES.txt +++ b/charts/flagsmith/templates/NOTES.txt @@ -24,6 +24,35 @@ for information about how to gain web access to the application. {{- end }} +{{- if not .Values.api.analytics.enabled }} + +###################################################### +##### Analytics capabilities are off! ##### +##### Chart-provisioned InfluxDB is deprecated. ##### +###################################################### + +If you were provisioning an InfluxDB instance for Flagsmith's +analytics with these charts, your data is safe, but no new data +will be written to it. + +*In a subsequent release, chart-provisioned InfluxDB and all related +values under the `influxdb2` key will be removed.* + +When you enable analytics by setting `api.analytics.enabled` +to `true`, the following database backend will be used for analytics, +in the order of preference: + + 1. External InfluxDB if `influxdbExternal.enabled` set to `true` + 2. Dedicated PostgreSQL specified by the `ANALYTICS_DATABASE_URL` + environment variable + 3. External PostgreSQL if `databaseExternal.enabled` set to `true` + 4. Chart-provisioned PostgreSQL + +Note that you can use a dedicated PostgreSQL instance by providing the +value for `ANALYTICS_DATABASE_URL` environment variable under the +`extraEnvFromSecret` key. +{{- end}} + {{- if not .Values.api.secretKey }} ###################################### diff --git a/charts/flagsmith/templates/_api_environment.yaml b/charts/flagsmith/templates/_api_environment.yaml index f4d00a3..caaad0c 100644 --- a/charts/flagsmith/templates/_api_environment.yaml +++ b/charts/flagsmith/templates/_api_environment.yaml @@ -13,19 +13,8 @@ secretKeyRef: name: {{ template "flagsmith.fullname" . }} key: DJANGO_SECRET_KEY -{{- if .Values.influxdb2.enabled }} -- name: INFLUXDB_URL - value: http://{{- template "flagsmith.influxdb.hostname" . -}}:80 -- name: INFLUXDB_BUCKET - value: {{ .Values.influxdb2.adminUser.bucket }} -- name: INFLUXDB_ORG - value: {{ .Values.influxdb2.adminUser.organization }} -- name: INFLUXDB_TOKEN - valueFrom: - secretKeyRef: - name: {{ template "flagsmith.influxdb.fullname" . }}-auth - key: admin-token -{{- else if .Values.influxdbExternal.enabled }} +{{- if .Values.api.analytics.enabled }} +{{- if .Values.influxdbExternal.enabled }} - name: INFLUXDB_URL value: {{ .Values.influxdbExternal.url | required "Must specify a URL for an external InfluxDB" }} - name: INFLUXDB_BUCKET @@ -42,6 +31,13 @@ name: {{ template "flagsmith.influxdb.fullname" . }}-external-auth key: admin-token {{- end }} +{{- else }} +- name: USE_POSTGRES_FOR_ANALYTICS + value: 'true' +{{- end }} +{{- else }} +- name: DISABLE_ANALYTICS_FEATURES + value: 'true' {{- end }} - name: DJANGO_ALLOWED_HOSTS value: '*' diff --git a/charts/flagsmith/values.yaml b/charts/flagsmith/values.yaml index 1cd9b75..a018fb8 100644 --- a/charts/flagsmith/values.yaml +++ b/charts/flagsmith/values.yaml @@ -4,7 +4,8 @@ api: tag: null # defaults to .Chart.AppVersion imagePullPolicy: IfNotPresent imagePullSecrets: [] - # Note that if setting this to false, need to set + # + # Note that if `separateApiAndFrontend` is `false`, you'll need to set # api.image.repository to flagsmith/flagsmith (or some other # repository hosting the image with combined frontend and backend) # and that the image tag exists (for flagsmith/flagsmith, >=2.10.0) @@ -13,6 +14,21 @@ api: # (unless explicitly switched off), but both are handled by the api # deployment's pods. separateApiAndFrontend: true + # + # If `analytics.enabled` flag is `true`, the following database backend + # will be used for analytics, in the order of preference: + # + # 1. External InfluxDB if `influxdbExternal.enabled` set to `true` + # 2. Dedicated PostgreSQL specified by the `ANALYTICS_DATABASE_URL` + # environment variable + # 3. External PostgreSQL if `databaseExternal.enabled` set to `true` + # 4. Chart-provisioned PostgreSQL + # + # Note that you can use a dedicated PostgreSQL instance by providing the + # value for `ANALYTICS_DATABASE_URL` environment variable under the + # `extraEnvFromSecret` key. + analytics: + enabled: false replicacount: 1 deploymentStrategy: null podAnnotations: {}