Operations
Backup And Restores
Custom Secret
Monitoring
tpl
New to KubeBlocks PostgreSQL? See the KubeBlocks PostgreSQL Operator for Kubernetes page for a feature overview, topology comparison, and Day-2 operations guide.
PostgreSQL is a powerful, open-source relational database management system known for its:
The KubeBlocks PostgreSQL Addon provides a complete solution for deploying and managing PostgreSQL clusters in Kubernetes environments. Key features include:
KubeBlocks simplifies PostgreSQL operations with comprehensive lifecycle management:
| Feature | Description |
|---|---|
| Horizontal Scaling | Scale replicas in/out to adjust capacity |
| Vertical Scaling | Adjust CPU/memory resources for PostgreSQL instances |
| Volume Expansion | Dynamically increase storage capacity without downtime |
| Restart Operations | Controlled cluster restarts with minimal disruption |
| Start/Stop | Temporarily suspend/resume cluster operations |
| Password Management | Ability to set and manage custom root password for the PostgreSQL cluster during creation |
| Dynamic Configuration | Modify PostgreSQL parameters without restarting |
| Custom Services | Expose specialized database endpoints |
| Switchover | Planned primary-replica role changes |
| Replica Management | Safely decommission or rebuild specific replicas |
| Version Upgrades | Perform minor version upgrades seamlessly |
| Advanced Scheduling | Customize pod placement and resource allocation |
| TLS Encryption | Enable/disable transport layer security |
| Monitoring | Integrated Prometheus metrics collection |
| Logging | Centralized logs via Loki Stack |
KubeBlocks supports multiple backup strategies for PostgreSQL:
| Backup Type | Method | Description |
|---|---|---|
| Full Backup | pg_basebackup | Native PostgreSQL utility for complete database snapshots |
| Full Backup | WAL-G | Efficient backup tool with compression and cloud storage support |
| Continuous | postgresql-pitr | Uploads PostgreSQL Write-Ahead Logging (WAL) files periodically to the backup repository, usually paired with pg-basebackup |
| Continuous | WAL-G Archive | Uploads PostgreSQL Write-Ahead Logging (WAL) files periodically to the backup repository, usually paired with wal-g |
The KubeBlocks PostgreSQL image ships with the following extensions pre-installed. Most can be activated with CREATE EXTENSION <name> without any additional installation steps.
| Extension | SQL Name | PG 12.22.0 | PG 14.18.0 | PG 15.13.0 | PG 16.9.0 | PG 17.5.0 | PG 18.1.0 | Enabled by default | Category |
|---|---|---|---|---|---|---|---|---|---|
| pgvector | vector | 0.7.4 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.0 | 0.8.1 | AI / Vector | |
| PostGIS | postgis | 3.5.3 | 3.5.3 | 3.5.3 | 3.5.3 | 3.5.3 | 3.6.1 | Geospatial | |
| TimescaleDB | timescaledb | 2.11.2 | 2.19.3 | 2.20.1 | 2.20.1 | 2.20.1 | 2.24.0 | Time-series | |
| pg_duckdb | pg_duckdb | — | 0.3.0 | 0.3.0 | 0.3.0 | 0.3.0 | 1.1.0 | Analytics | |
| roaringbitmap | roaringbitmap | — | — | — | — | — | 1.1 | Analytics | |
| pg_trgm | pg_trgm | 1.4 | 1.6 | 1.6 | 1.6 | 1.6 | 1.6 | Search | |
| pg_stat_statements | pg_stat_statements | 1.7 | 1.9 | 1.10 | 1.10 | 1.11 | 1.12 | ✓ | Observability |
| pgaudit | pgaudit | 1.4.3 | 1.6.3 | 1.7.1 | 16.1 | 17.1 | 18.0 | Security | |
| pg_cron | pg_cron | 1.6 | 1.6 | 1.6 | 1.6 | 1.6 | 1.6 | ✓ | Scheduling |
| pg_partman | pg_partman | 4.7.4 | 5.2.4 | 5.2.4 | 5.2.4 | 5.2.4 | 5.4.0 | Data Management | |
| pglogical | pglogical | 2.4.5 | 2.4.5 | 2.4.5 | 2.4.5 | 2.4.5 | 2.4.6 | Replication |
Extensions marked Enabled by default are loaded automatically via shared_preload_libraries and ready to use without any additional steps. All others require a one-time CREATE EXTENSION <sql-name> per database.
pgvector adds a vector data type and similarity search operators to PostgreSQL. Store embedding vectors generated by AI models and run approximate nearest-neighbor (ANN) searches with IVFFlat or HNSW indexes — the foundation for semantic search and RAG pipelines directly inside your database.
CREATE EXTENSION vector;
CREATE TABLE items (id serial, embedding vector(1536));
SELECT * FROM items ORDER BY embedding <-> '[0.1, 0.2, ...]' LIMIT 10;
PostGIS is the industry-standard geospatial extension for PostgreSQL. It adds geometry and geography data types, spatial indexes (GiST), and hundreds of functions for distance calculations, intersection tests, buffer zones, and coordinate transforms — essential for any application working with location data.
CREATE EXTENSION postgis;
SELECT ST_Distance(
ST_MakePoint(116.4, 39.9)::geography, -- Beijing
ST_MakePoint(121.5, 31.2)::geography -- Shanghai
);
TimescaleDB extends PostgreSQL with hypertables — automatically partitioned tables optimized for time-ordered inserts and range queries. It also provides continuous aggregates (auto-refreshing materialized views), data retention policies, and native compression for historical data. Best suited for monitoring metrics, IoT sensor data, and financial tick data.
CREATE EXTENSION timescaledb;
CREATE TABLE metrics (time TIMESTAMPTZ NOT NULL, value DOUBLE PRECISION);
SELECT create_hypertable('metrics', 'time');
pg_duckdb embeds the DuckDB OLAP engine inside PostgreSQL. Complex aggregations and analytical queries run through DuckDB's vectorized execution engine, which can be orders of magnitude faster than PostgreSQL's row-based executor for wide-table scans. Available on PG14 and later (not available on PG12). Note that the bundled version varies significantly by PostgreSQL major version: 0.3.0 on PG14–PG17, 1.1.0 on PG18.
CREATE EXTENSION pg_duckdb;
SELECT region, sum(revenue) FROM orders GROUP BY region; -- runs via DuckDB
roaringbitmap provides a compressed bitmap data type optimized for large integer set operations. Intersections, unions, and cardinality counts on sets of millions of user IDs run in milliseconds. Ideal for audience segmentation, permission systems, and analytics pre-aggregation. Available on PG18 only — not present in PG12–PG17.
CREATE EXTENSION roaringbitmap;
SELECT rb_and(bitmap_active, rb_and(bitmap_female, bitmap_beijing))
FROM user_segments;
pg_trgm enables trigram-based fuzzy text search. Its key benefit is making LIKE '%keyword%' queries index-friendly via GiST or GIN indexes, eliminating full-table scans. It also provides a similarity() function for ranking results by how closely strings match.
CREATE EXTENSION pg_trgm;
CREATE INDEX ON products USING gin(name gin_trgm_ops);
SELECT name, similarity(name, 'iphone') AS score
FROM products WHERE name % 'iphone' ORDER BY score DESC;
pg_stat_statements records cumulative execution statistics — call count, total and mean execution time, rows returned — for every distinct SQL statement. It is the primary tool for identifying slow queries and is a dependency of most PostgreSQL monitoring systems. Enabled automatically; query the pg_stat_statements view directly.
SELECT query, calls, mean_exec_time, total_exec_time
FROM pg_stat_statements ORDER BY total_exec_time DESC LIMIT 10;
pgaudit produces detailed audit logs of SQL activity beyond what PostgreSQL's standard logging captures. You can configure it to log specific statement classes (DDL, DML, SELECT, or all), specific roles, or specific objects — satisfying compliance requirements such as SOC 2, HIPAA, and PCI DSS.
CREATE EXTENSION pgaudit;
SET pgaudit.log = 'ddl, write';
pg_cron runs scheduled SQL tasks inside the database using standard cron syntax. No external scheduler or application code is needed — useful for recurring maintenance tasks like VACUUM, data archival, or report generation.
CREATE EXTENSION pg_cron;
SELECT cron.schedule('nightly-vacuum', '0 3 * * *', 'VACUUM ANALYZE orders');
pg_partman automates partition lifecycle management for PostgreSQL native partitioned tables. It creates future partitions on a schedule, drops or detaches expired partitions based on a retention policy, and handles the bookkeeping that is otherwise error-prone when done manually. Works with both time-based and ID-based partition strategies.
CREATE EXTENSION pg_partman;
SELECT partman.create_parent('public.logs', 'created_at', 'native', 'daily');
pglogical implements logical replication at the table level, independent of PostgreSQL's built-in streaming replication. Key capabilities include selective table replication, cross-major-version replication (e.g., PG14 → PG17 for zero-downtime upgrades), and bidirectional or multi-master replication topologies.
CREATE EXTENSION pglogical;
-- On the provider node:
SELECT pglogical.create_node(node_name := 'provider', dsn := 'host=... dbname=mydb');
SELECT pglogical.replication_set_add_all_tables('default', ARRAY['public']);
KubeBlocks PostgreSQL Addon supports these PostgreSQL versions:
| Major Version | Supported Minor Versions |
|---|---|
| 12 | 12.14.0, 12.14.1, 12.15.0, 12.22.0 |
| 14 | 14.7.2, 14.8.0, 14.18.0 |
| 15 | 15.7.0, 15.13.0 |
| 16 | 16.4.0, 16.9.0 |
| 17 | 17.5.0 |
| 18 | 18.1.0 |
The list of supported versions can be found by following command:
kubectl get cmpv postgresql