github.com/codefresh-io/kcfi@v0.0.0-20230301195427-c1578715cc46/docs/external-dbs/postgres.md (about)

     1  # Configuring external Postgres database
     2  
     3  It is possible to configure Codefresh to work with user-provided Postgres database service, in case if default one provided automatically within Codefresh installation is not applicable for the user. This document describes how to do that.
     4  
     5  #### Configuration steps
     6  
     7  All the configuration comes down to putting a set of correct values into your Codefresh configuration file `config.yaml`, which is present in `your/stage-dir/codefresh` directory. During the installation, Codefresh will run a seed job, using the values described in the below steps:
     8  
     9  1. Specify a user name `global.postgresSeedJob.user` and password `global.postgresSeedJob.password` for a seed job. This must be a privileged user allowed to create databases and roles. It will be used only by the seed job to create the needed database and a user.
    10  2. Specify a user name `global.postgresUser` and password `global.postgresPassword` to be used by Codefresh installation. A user with the name and password will be created by the seed job and granted with required privileges to access the created database.
    11  3. Specify a database name `global.postgresDatabase` to be created by the seed job and used by Codefresh installation.
    12  4. Specify `global.postgresHostname` and optionally `global.postgresPort` (`5432` is a default value).
    13  5. Disable the postgres subchart installation with the `postgresql.enabled: false` value, because it is not needed in this case.
    14  
    15  Below is an example of a relevant piece of configuration YAML would look like:
    16  
    17  ```yaml
    18  global:
    19    postgresSeedJob:
    20      user: <POSTGRES SEED USER>
    21      password: <POSTGRES SEED PASSWORD>
    22    postgresUser: <POSTGRES USER>
    23    postgresPassword: <POSTGRES PASSWORD>
    24    postgresDatabase: codefresh
    25    postgresHostname: <POSTGRES HOST>
    26    postgresPort: 5432
    27  
    28  postgresql:
    29    enabled: false
    30  ```
    31  
    32  #### Running the seed job manually
    33  
    34  In case if you'd prefer running the seed job manually, you could do it by using a script present in `your/stage-dir/codefresh/addons/seed-scripts` directory named `postgres-seed.sh`. The script takes the following set of variables you need to have set before running it:
    35  
    36  ```
    37  POSTGRES_SEED_USER="postgres"
    38  POSTGRES_SEED_PASSWORD="zDyGp79XyZEqLq7V"
    39  POSTGRES_USER="cf_user"
    40  POSTGRES_PASSWORD="fJTFJMGV7sg5E4Bj"
    41  POSTGRES_DATABASE="codefresh"
    42  POSTGRES_HOST="my-postgres.ccjog7pqzunf.us-west-2.rds.amazonaws.com"
    43  POSTGRES_PORT="5432"
    44  ```
    45  The variables have the same meaning as the configuratoin values described in the above section of this document.
    46  
    47  However you **still need to specify a set of values** in the Codefresh config file as described in the section above, but with the whole **`postgresSeedJob` section ommitted**, like this:
    48  
    49  ```yaml
    50  global:
    51    postgresUser: <POSTGRES USER>
    52    postgresPassword: <POSTGRES PASSWORD>
    53    postgresDatabase: codefresh
    54    postgresHostname: <POSTGRES HOST>
    55    postgresPort: 5432
    56  
    57  postgresql:
    58    enabled: false
    59  ```