Version 14 or higher is required.
Bundled PostgreSQL#
The unified formance Helm chart includes a Bitnami PostgreSQL instance enabled by default:
postgresql:
enabled: true # defaultThis deploys a single-node PostgreSQL server in your formance-system namespace. It's useful for development and testing, but not recommended for production workloads.
The bundled instance uses the credentials defined in global.postgresql.auth:
global:
postgresql:
host: "postgresql"
auth:
username: formance
password: formance
database: formanceThe bundled PostgreSQL does not include persistent storage by default. Do not rely on it for production data.
Portal and Console-v3 do not use global.postgresql.auth.database: each app needs its own database. See Portal and Console Databases.
External PostgreSQL#
For production, use a managed PostgreSQL service and disable the bundled instance:
postgresql:
enabled: false
global:
postgresql:
host: "my-postgres.example.com"
additionalArgs: "sslmode=require"
auth:
username: "formance"
password: "your-secure-password"
database: "formance"
existingSecret: "" # or reference a Kubernetes secret
secretKeys:
adminPasswordKey: ""
userPasswordKey: ""
service:
ports:
postgresql: 5432Use global.postgresql.auth.existingSecret to reference a Kubernetes Secret instead of storing passwords in your values file.
Portal and Console Databases#
Portal and Console-v3 each need their own database, separate from the other app and from global.postgresql.auth.database. If both apps share a database, the migrations of one app collide with the migrations of the other, and users cannot log in.
The formance chart has given each app its own database since its first version, so formance chart installs are not affected. The problem only affects the cloudprem chart installed on its own, before version 6.4.2: these versions sent both apps to global.postgresql.auth.database. From cloudprem 6.4.2, portal and console are the defaults.
Set the databases explicitly anyway, so that your values file does not depend on the chart version. With the formance chart:
cloudprem:
portal:
config:
postgresql:
auth:
database: portal
console-v3:
config:
postgresql:
auth:
database: consoleWith the cloudprem chart installed on its own, the keys are at the root:
portal:
config:
postgresql:
auth:
database: portal
console-v3:
config:
postgresql:
auth:
database: consoleDatabase Prerequisites#
If the databases set in auth.database don't exist, the migration jobs create them, which needs the CREATEDB privilege. Otherwise, create them beforehand, owned by the application user. With the values above:
CREATE DATABASE portal OWNER <user>;
CREATE DATABASE console OWNER <user>;Up to v4.1.1, the migration jobs also require these exact names, whatever auth.database says, and CONNECT on the postgres database.
Upgrade from Portal and Console-v3 1.x#
Portal and Console-v3 store their sessions in PostgreSQL since v2.0.0, and their migration jobs look for the portal and console databases since v2.6.0. If you upgrade a standalone cloudprem install from 1.x, set the two databases above and meet the prerequisites before you upgrade.
Recover from a Shared Database#
If both apps used one database, you see one of these symptoms:
- The migration job fails with
permission denied to create database(v4.1.1 and earlier). - The migration job succeeds, but login fails with
Failed query: insert into "session" ... on conflict ("id","organization_id"). - From v4.2.0, the migration job fails with
Database "<name>" already holds another application's migrations. The job stops before it writes anything.
To recover, point each app at its own database and upgrade again. The migrations run from scratch in the new databases, and users must log in again.
Keep global.postgresql.auth.database as it is: Membership still uses it.
To keep the data of the app that worked on the shared database, and to clean up that database, follow Recovering from a shared database in the cloudprem chart README.
Configure PostgreSQL URI via Helm Values#
The Formance Operator uses Settings CRDs to configure database connections for each stack. You can create these Settings declaratively through Helm values using regions.settings:
regions:
settings:
postgres-uri:
key: "postgres.*.uri"
value: "postgresql://formance:formance@my-postgres.example.com:5432?disableSSLMode=true"This creates a Settings resource that applies the PostgreSQL URI to all stacks and all modules (the * wildcard).
Scope to Specific Stacks#
To target a specific stack, add a stacks field:
regions:
settings:
postgres-uri:
key: "postgres.*.uri"
stacks:
- "my-stack"
value: "postgresql://formance:formance@my-postgres.example.com:5432?disableSSLMode=true"Per-Module Configuration#
Use the module name instead of * to configure different PostgreSQL servers per module:
regions:
settings:
postgres-ledger:
key: "postgres.ledger.uri"
value: "postgresql://formance:formance@pg-ledger.example.com:5432?disableSSLMode=true"
postgres-payments:
key: "postgres.payments.uri"
value: "postgresql://formance:formance@pg-payments.example.com:5432?disableSSLMode=true"Create Database Settings Manually#
If you prefer to manage Settings CRDs directly with kubectl, you can create them manually.
Option 1: Use the same server for all modules#
Set up a PostgreSQL cluster for all modules of the formance-dev stack. Each module gets its own database, named {stackName}-{module}.
The database name uses the format {stackName}-{module}.
apiVersion: formance.com/v1beta1
kind: Settings
metadata:
name: formance-dev-postgres-uri
spec:
key: postgres.*.uri
stacks:
- 'formance-dev'
value: postgresql://formance:formance@postgresql.formance-system.svc:5432?disableSSLMode=trueOption 2: Use different servers for each module#
---
apiVersion: formance.com/v1beta1
kind: Settings
metadata:
name: formance-dev-ledger-postgres-uri
spec:
key: postgres.ledger.uri
stacks:
- 'formance-dev'
value: postgresql://formance:formance@postgresql-ledger.formance-system.svc:5432?disableSSLMode=true
---
apiVersion: formance.com/v1beta1
kind: Settings
metadata:
name: formance-dev-payments-postgres-uri
spec:
key: postgres.payments.uri
stacks:
- 'formance-dev'
value: postgresql://formance:formance@postgresql-payments.formance-system.svc:5432?disableSSLMode=trueOption 3: Use PostgreSQL on AWS RDS with an IAM role#
apiVersion: v1
kind: ServiceAccount
metadata:
name: aws-rds-access-role
namespace: formance-system
labels:
formance.com/stack: any
annotations:
eks.amazonaws.com/role-arn: arn:aws:iam::AWS_ACCOUNT_ID:role/AWS_ROLE_NAME
---
apiVersion: formance.com/v1beta1
kind: Settings
metadata:
name: formance-dev-aws-service-account
spec:
stacks:
- formance-dev
key: aws.service-account
value: aws-rds-access-role
---
apiVersion: formance.com/v1beta1
kind: Settings
metadata:
name: formance-dev-postgres-uri
spec:
key: postgres.*.uri
stacks:
- 'formance-dev'
value: postgresql://formance@postgresql.formance-system.svc:5432