mirror of
https://github.com/andwati/zitadel.git
synced 2026-10-28 10:02:15 +00:00
# Which Problems Are Solved When Postgres was not ready when the API was started, the API failed immediately. This made task orchestration hard, especially in a platform agnostic way: - The current health check in the Nx target `@zitadel/api:prod` uses the timeout command, which is not installed on all platforms and behaves unpredictably - The current health check in the Nx target `@zitadel/api:prod` requires the DB to have been started using `@zitadel/zitadel:db` # How the Problems Are Solved - Additional configuration option `Database.Postgres.AwaitInitialConn` is added and defaults to *0m* for backwards compatibility. - If a duration is configured, the API retries to ping the database until it succeeds - The API sleeps for a second between each ping. - It emits an info-level log with the error on each try. - When the configured duration times out before the ping is successful, the error is returned and the command exits with a failure code. - When the ping succeeds within the configured duration, the API goes on with the init, setup or start phase. # Additional Context - Relates to internally reported problems with the current DB health check command [here](https://zitadel.slack.com/archives/C07EUL5H83A/p1759915009839269?thread_ts=1759912259.410789&cid=C07EUL5H83A) and [here](https://zitadel.slack.com/archives/C07EUL5H83A/p1759918324246249?thread_ts=1759912259.410789&cid=C07EUL5H83A).
57 lines
1.6 KiB
Plaintext
57 lines
1.6 KiB
Plaintext
## ZITADEL with Postgres
|
|
|
|
PostgreSQL is the default database for ZITADEL due to its reliability, robustness, and adherence to SQL standards. It is well-suited for handling the complex data requirements of an identity management system.
|
|
|
|
If you are using Zitadel v2 and want to use a PostgreSQL database, you can [overwrite the default configuration](../configure/configure.mdx).
|
|
|
|
Currently, versions 14 to 17 are supported.
|
|
|
|
Postgres can be configured as follows:
|
|
```yaml
|
|
Database:
|
|
postgres:
|
|
Host: localhost
|
|
Port: 5432
|
|
Database: zitadel
|
|
AwaitInitialConn: 5m
|
|
MaxOpenConns: 15
|
|
MaxIdleConns: 10
|
|
MaxConnLifetime: 1h
|
|
MaxConnIdleTime: 5m
|
|
Options:
|
|
User:
|
|
Username: zitadel
|
|
Password: zitadel
|
|
SSL:
|
|
Mode: disable
|
|
RootCert:
|
|
Cert:
|
|
Key:
|
|
Admin:
|
|
Username: postgres
|
|
Password: postgres
|
|
SSL:
|
|
Mode: disable
|
|
RootCert:
|
|
Cert:
|
|
Key:
|
|
```
|
|
|
|
The admin user is only needed for the installation step but can also be avoided
|
|
by preparing the necessary requirements:
|
|
|
|
* the zitadel user
|
|
* the zitadel database
|
|
* granting required permissions to the zitadel user
|
|
|
|
```sql
|
|
CREATE ROLE zitadel LOGIN;
|
|
CREATE DATABASE zitadel;
|
|
GRANT CONNECT, CREATE ON DATABASE zitadel TO zitadel;
|
|
```
|
|
|
|
Don't forget to adjust `pg_hba.conf` and set a password for the zitadel user.
|
|
|
|
With the setup done, follow the [phases guide](/docs/self-hosting/manage/updating_scaling#separating-init-and-setup-from-the-runtime)
|
|
to run the init and then setup phase to get all necessary tables and data set up.
|