bitnami / charts

Bitnami Helm Charts
https://bitnami.com
Other
8.83k stars 9.12k forks source link

[bitnami/wordpress] Switch from database in namespace to external database in AWS RDS Mariadb #28991

Closed chary1112004 closed 4 days ago

chary1112004 commented 3 weeks ago

Name and Version

bitnami/wordpress 23.1.7

What architecture are you using?

None

What steps will reproduce the bug?

Step 1: Deploy mariadb in same namespace Step 2: Deploy wordpress Step 3: Switch mariadb in same namespace to external database in aws rds mariadb Step 4: Verify connection in mariadb successfully

mariadb -h <db connection> --ssl-ca=/tmp/global-bundle.pem -u admin -D bitnami_wordpress -p
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 63
Server version: 10.11.8-MariaDB-log managed by https://aws.amazon.com/rds/

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [bitnami_wordpress]>

Are you using any custom parameters or values?

  ## MariaDB chart configuration
  ## ref: https://github.com/bitnami/charts/blob/main/bitnami/mariadb/values.yaml
  ##
  mariadb:
    ## @param mariadb.enabled Deploy a MariaDB server to satisfy the applications database requirements
    ## To use an external database set this to false and configure the `externalDatabase.*` parameters
    ##
    enabled: false

  ## External Database Configuration
  ## All of these values are only used if `mariadb.enabled=false`
  ##
  externalDatabase:
    ## @param externalDatabase.host External Database server host
    ##
    host: <host in rds.amazonaws.com>
    ## @param externalDatabase.port External Database server port
    ##
    port: 3306
    ## @param externalDatabase.user External Database username
    ##
    user: bn_wordpress
    ## @param externalDatabase.password External Database user password
    ##
    password: ""
    ## @param externalDatabase.database External Database database name
    ##
    database: bitnami_wordpress
    ## @param externalDatabase.existingSecret The name of an existing secret with database credentials. Evaluated as a template
    ## NOTE: Must contain key `mariadb-password`
    ## NOTE: When it's set, the `externalDatabase.password` parameter is ignored
    ##
    existingSecret: "mariadb"
  ## @param extraEnvVars Array with extra environment variables to add to the WordPress container
  ## e.g:
  ## extraEnvVars:
  ##   - name: FOO
  ##     value: "bar"
  ##
  extraEnvVars:
    - name: WORDPRESS_DATABASE_SSL_CA_FILE
      value: /tmp/ssl/global-bundle.pem
    - name: WORDPRESS_ENABLE_DATABASE_SSL
      value: "yes"

  ## Add additional volumes and mounts, e. g. for custom keystore
  extraVolumes: |
    - name: ssl
      configMap:
        name: mariadb-ssl-configmap

  extraVolumeMounts: |
    - name: ssl
      mountPath: /tmp/ssl

What is the expected behavior?

Wordpress could connect to external mariadb that enable ssl instead of database is deployed same namespace

What do you see instead?

Log in wordpress:

wordpress 02:32:13.01 INFO  ==> Trying to connect to the database server
wordpress 02:32:13.02 DEBUG ==> Getting DB_NAME from WordPress configuration
wordpress 02:32:13.42 DEBUG ==> Getting DB_USER from WordPress configuration
wordpress 02:32:13.83 DEBUG ==> Getting DB_PASSWORD from WordPress configuration
wordpress 02:32:14.30 DEBUG ==> Getting DB_HOST from WordPress configuration
/opt/bitnami/mysql/bin/mysql: Deprecated program name. It will be removed in a future release, use '/opt/bitnami/mysql/bin/mariadb' instead
wordpress 02:32:14.72 DEBUG ==> Executing SQL command:
SELECT 1
/opt/bitnami/mysql/bin/mysql: Deprecated program name. It will be removed in a future release, use '/opt/bitnami/mysql/bin/mariadb' instead
ERROR 2002 (HY000): Can't connect to server on 'mariadb-primary.wordpress.svc.cluster.local' (115)
/opt/bitnami/mysql/bin/mysql: Deprecated program name. It will be removed in a future release, use '/opt/bitnami/mysql/bin/mariadb' instead
wordpress 02:32:19.77 DEBUG ==> Executing SQL command:
SELECT 1
/opt/bitnami/mysql/bin/mysql: Deprecated program name. It will be removed in a future release, use '/opt/bitnami/mysql/bin/mariadb' instead

Additional information

No response

migruiz4 commented 1 week ago

Hi @chary1112004,

I'm sorry for the late response.

The bitnami/wordpress has the value overrideDatabaseSettings which is designed for this specific scenario.

That value will set the env variable 'WORDPRESS_OVERRIDE_DATABASE_SETTINGS' to true, triggering the following logic in the container: https://github.com/bitnami/containers/blob/main/bitnami/wordpress/6/debian-12/rootfs/opt/bitnami/scripts/libwordpress.sh#L377-L395

Otherwise, the Wordpress container won't update the database and will continue to use the database set in the persisted configuration file.

chary1112004 commented 4 days ago

Hi @migruiz4,

Thank you for your information. As we have wordpress for testing then I have done workaround by delete pv and pvc. Maybe in future we will need to use this one.

Then we could close this ticket.

Thanks!