Overview
PostgreSQL provides a shared relational database for microservices. It’s deployed with automatic database provisioning for each service and Prometheus metrics integration.Configuration
Nixidy Module (nixidy/env/local/postgresql.nix)
Deployment
PostgreSQL runs as a StatefulSet in thedatabase namespace:
- Chart: Bitnami PostgreSQL
- Replicas: 1 (primary only, no replicas)
- Namespace:
database - Persistence: 2Gi PVC
Authentication
Default Credentials (Development)
- Username:
devuser - Password:
devpass - Default database:
postgres
Connection String
Database Provisioning
Databases are automatically created via initdb scripts:Service Databases
| Database | Service | Purpose |
|---|---|---|
auth_db | auth-service | User authentication |
lang_db | language-service | Language/i18n data |
greeter_db | greeter-service | Greeter service state |
caller_db | caller-service | Caller service state |
gateway_db | gateway-service | API gateway state |
devuser with full privileges.
Persistence
- Size: 2Gi (sufficient for local development)
- Access mode: ReadWriteOnce (single node)
- Storage class: Cluster default
Observability
Metrics
PostgreSQL metrics are exported and scraped by Prometheus:Metrics Exporter
The Bitnami chart includespostgres_exporter, which provides:
- Connection pool stats
- Query performance
- Database size
- Table/index statistics
- Replication lag (if replicas enabled)
- Transaction rates
- Lock statistics
ServiceMonitor
Prometheus automatically discovers PostgreSQL metrics:Grafana Dashboards
PostgreSQL metrics can be visualized in Grafana:Service Endpoint
- Internal URL:
postgresql.database:5432 - Namespace:
database - Protocol: PostgreSQL wire protocol
Client Configuration
Go (pgx)
Node.js (pg)
High Availability
Local deployment uses single primary (no HA):- Read replicas
- Replication
- Automatic failover
- Backup/restore
Schema Management
Migrations
Migrations are handled by application services:- Go services: migrate, goose, or embedded migrations
- Node.js services: knex, sequelize, or typeorm
Init Scripts
Additional init scripts can be added:Backup & Restore
Manual Backup
Restore
Automated Backups
For production, configure:- WAL archiving
- Point-in-time recovery (PITR)
- pg_basebackup to S3
Troubleshooting
Check Logs
Connect to psql
Check Database Size
Connection Count
Resource Limits
Default resource requests/limits from Bitnami chart:Related Components
- Prometheus - Metrics collection
- Grafana - Database metrics visualization
- Microservices - Database clients (in separate repository)