k8s-at-home / charts

⚠️ Deprecated : Helm charts for applications you run at home
https://docs.k8s-at-home.com
Apache License 2.0
1.45k stars 621 forks source link

[firefly-iii] Unable to use external database #1696

Open brandan-schmitz opened 2 years ago

brandan-schmitz commented 2 years ago

Helm chart name

firefly-iii

Helm chart version

0.1.0

Container name

firefly-iii/core

Container tag

version-5.7.9

Description

When configuring this chart and applying the DB_CONNECTION, DB_HOST, DB_PORT, DB_DATABASE, DB_USERNAME, and DB_PASSWORD variables, they are overridden by the settings for MariaDB and PostgreSQL. This makes this chart unusable when using an external database already configured as if both the options for using the sub-charts for MariaDB and PostgreSQL are disabled then it overwrites any of the DB related variables with per-configured items in the template.

Expected result

If you specified database configuration values and do not enable either of the sub-charts for the different database engines then it should use the values you specified in the configuration and not overwrite them.

Helm values to reproduce

image:
  tag: version-5.7.9

env:
  APP_ENV: production
  SITE_OWNER: my-email@my-domain.com
  APP_KEY: abcdefghijklmnopqrstuvwxyzABCDEF
  TZ: America/Chicago
  DB_CONNECTION: mysql
  DB_HOST: mariadb-mariadb-galera.database-servers.svc
  DB_PORT: 3306
  DB_DATABASE: firefly
  DB_USERNAME: firefly
  DB_PASSWORD: firefly

Additional Information

A suggestion for this would be to move all database settings into one section. If mariadb is enabled then externalDatabase and postgresql values would be ignored, likewise for the other two. I imagine this new section would look something like this:

database:
  # -- Enable and configure mariadb subchart under this key.
  #    For more options see [mariadb chart documentation](https://github.com/bitnami/charts/tree/master/bitnami/mariadb)
  # @default -- See values.yaml
  # https://github.com/bitnami/charts/tree/master/bitnami/mariadb/#installing-the-chart
  mariadb:
    enabled: false
    # primary:
    #   persistence:
    #     enabled: true
    auth:
      rootPassword: ""
      username: "firefly"
      # password: "password"
      database: "firefly"

  # -- Enable and configure postgresql subchart under this key.
  #    For more options see [postgresql chart documentation](https://github.com/bitnami/charts/tree/master/bitnami/postgresql)
  # @default -- See values.yaml
  # https://github.com/bitnami/charts/tree/master/bitnami/postgresql/#installing-the-chart
  postgresql:
    enabled: false
    auth:
      # postgresPassword: ""
      username: "firefly"
      # password: ""
      database: "firefly"
    # postgresqlUsername: "firefly"
    # postgresqlPassword: ""
    # postgresqlDatabase: "firefly"
    # persistence:
    #   enabled: true
    #   storageClass:
    #   accessModes:
    #     - ReadWriteOnce

  # Enables connecting to an external database server. Enabling this will disable settings for either of the above two database types.
  externalDatabase:
    # Enabled or disable the connection to an external database server
    enabled: true
    # Set the database server type. Supported types are mysql and pgsql. sqlite is not supported as that is local to the system.
    # This maps to the DB_CONNECTION field
    databaseType: mysql
    username: firefly
    password: firefly
    database: firefly
    host: externaldatabase.com
    port: 3306

Repo link

No response

brandan-schmitz commented 2 years ago

Alternatively remove the logic for the databases and subcharts to fall in line with #1572 and simply have a section called externalDatabase and have it default to not being enabled which would use sqlite in the settings which firefly-iii supports by default:

externalDatabase:
  # Enabled or disable the connection to an external database server.
  # If disabled firefly-iii will use the built in sqlite database.
  enabled: true
  # Set the database server type. Supported types are mysql and pgsql. sqlite is not supported as that is local to the system.
  # This maps to the DB_CONNECTION field
  databaseType: mysql
  username: firefly
  password: firefly
  database: firefly
  host: externaldatabase.com
  port: 3306

If the user disables the external database, it should be noted that they should enable persistence for the built in sqlite database located at /var/www/html/storage/database/database.sqlite:

# -- Configure persistence settings for the chart under this key.
# @default -- See values.yaml
persistence:
  config:
    enabled: false
  database:
    # -- Enable persistence for the built in sqlite database. This is only necessary
    # if not using an external database configured in the externalDatabase section.
    enabled: false
    mountPath: "/var/www/html/storage/database"
    accessMode: ReadWriteOnce
    size: 8Gi
    retain: true
  uploads:
    # -- Enable persistence for uploading attachments for transactions
    enabled: false
    mountPath: "/var/www/html/storage/upload"
    accessMode: ReadWriteOnce
    size: 1Gi
    retain: true