Version v3.7.0 of the documentation is no longer actively maintained. The site that you are currently viewing is an archived snapshot.
For up-to-date documentation, see the latest version.
Declarative infrastructure and database management with YAML-driven configuration
Pigsty provides a declarative interface: Describe everything in a config file, and Pigsty operates it to the desired state with idempotent playbooks. It works like Kubernetes CRDs & Operators but for databases and infrastructures on any nodes: bare metal or virtual machines.
Note
Infra as Code, Database as Code: Declarative API & Idempotent Playbooks, GitOPS works like a charm.
Declare Module
You can declare modules on a single node:
# infra cluster for proxy, monitor, alert, etc...infra:{hosts:{10.10.10.10:{infra_seq:1}}}# minio cluster, s3 compatible object storageminio:{hosts:{10.10.10.10:{minio_seq:1 } }, vars:{minio_cluster:minio } }# etcd cluster for ha postgres DCSetcd:{hosts:{10.10.10.10:{etcd_seq:1 } }, vars:{etcd_cluster:etcd } }# postgres example cluster: pg-metapg-meta:{hosts:{10.10.10.10:{pg_seq:1, pg_role:primary } }, vars:{pg_cluster:pg-meta } }
And apply with playbooks:
./infra.yml -l infra # init infra module on node 10.10.10.10./etcd.yml -l etcd # init etcd module on node 10.10.10.10./minio.yml -l minio # init minio module on node 10.10.10.10./pgsql.yml -l pg-meta # init pgsql module on node 10.10.10.10
Declare Cluster
To create a three-node HA postgres cluster with streaming replication:
pg-meta:hosts:10.10.10.10:{pg_seq:1, pg_role:primary }vars:pg_cluster:pg-metapg_databases:- name:metabaseline:cmdb.sqlcomment:pigsty meta databaseschemas:[pigsty]extensions:- {name:adminpack, schema:pg_catalog }- {name:postgis, schema:public }- {name:timescaledb, schema:public }pg_users:- {name:dbuser_meta, password:DBUser.Meta, pgbouncer:true, roles:[dbrole_admin], comment:pigsty admin user }- {name:dbuser_view, password:DBUser.Viewer, pgbouncer:true, roles:[dbrole_readonly], comment:pigsty read-only user }pg_services:- {name:primary, port:5433, dest:default }- {name:replica, port:5434, dest:default, selector:"[]"}- {name:default, port:5436, dest:postgres }- {name:offline, port:5438, dest:postgres, selector:"[]"}pg_hba_rules:- {user:dbuser_view, db:all, addr:infra, auth:pwd, title:'allow view user from infra nodes'}pgb_hba_rules:- {user:dbuser_view, db:all, addr:infra, auth:pwd, title:'allow view user from infra nodes'}
Declare Access Control
Define advanced access control rules:
pg_hba_rules:- {user:'${dbsu}', db:all, addr:local, auth:ident, title:'dbsu access via local os user ident'}- {user:'${dbsu}', db:replication, addr:local, auth:ident, title:'dbsu replication from local os ident'}- {user:'${repl}', db:replication, addr:'${ip}/32', auth:pwd, title:'replicator replication from ${ip}'}- {user:'${repl}', db:postgres, addr:'${ip}/32', auth:pwd, title:'replicator postgres db from ${ip}'}- {user:'${monitor}', db:all, addr:'${ip}/32', auth:pwd, title:'monitor from ${ip}'}- {user:'${monitor}', db:all, addr:infra, auth:pwd, title:'monitor from infra nodes'}- {user:'${admin}', db:all, addr:infra, auth:ssl, title:'admin @ infra nodes with pwd & ssl'}- {user:'+dbrole_readonly', db:all, addr:'${vip}/32', auth:ssl, title:'allow readonly role from ${vip} with ssl'}- {user:'+dbrole_offline', db:all, addr:'${vip}/32', auth:ssl, title:'allow offline role from ${vip} with ssl'}- {user:dbuser_meta, db:meta, addr:'10.0.0.0/8', auth:ssl, title:'allow meta user from 10.0.0.0/8 with ssl'}
Pigsty enables you to describe your entire infrastructure declaratively and manage it through code, providing consistency, repeatability, and scalability for your database and infrastructure operations.