PGO (Crunchy Data Postgres Operator) is a production-grade Kubernetes operator that manages the full lifecycle of PostgreSQL clusters, including deployment, high availability via Patroni, backup/restore via pgBackRest, connection pooling via PgBouncer, monitoring via OpenTelemetry and pgMonitor, and a web UI via pgAdmin. The operator uses custom resource definitions (CRDs) for PostgresCluster, PGAdmin, and PGUpgrade, and reconciles desired state using controller-runtime with server-side apply. It manages StatefulSets, PVCs, Services, ConfigMaps, Secrets, Jobs, and RBAC across multiple namespaces. Architecturally, the operator is a single binary with multiple controllers (postgrescluster, standalone_pgadmin, pgupgrade) and sidecar containers for pgBackRest, PgBouncer, pgAdmin, and the OpenTelemetry collector. It uses feature gates to enable optional capabilities like volume snapshots, auto-grow volumes, and OpenTelemetry logging/metrics. The codebase is well-structured with distinct packages for naming conventions, PKI certificate management, PostgreSQL parameter management, and shell command construction. Extensive unit and e2e tests (using kuttl and chainsaw) cover most scenarios, including backup/restore, scaling, upgrades, and security contexts. Key external dependencies include controller-runtime, client-go, Patroni, pgBackRest, PgBouncer, pgAdmin, OpenTelemetry SDK, and pg_query_go for SQL parsing. The operator is deployed via Kustomize and supports multiple PostgreSQL versions (11-18) with PostGIS extensions.
This repository is a comprehensive guide and automation suite for setting up a production-like Kubernetes cluster on local machines (macOS/ARM64 and Linux/AMD64). It combines educational documentation with working bash scripts that automate the entire deployment process from VM provisioning to Kubernetes component installation. The codebase consists primarily of shell scripts for infrastructure automation (VM setup, network configuration, certificate generation, Kubernetes component deployment) and JSON/YAML configuration files for Kubernetes and TLS certificates. The architecture follows a multi-stage deployment pattern: host preparation → VM provisioning → security bootstrapping → control plane setup → worker node setup → cluster services installation. Key entry points include setupall.sh (master orchestration script), auth/genauth.sh (certificate generation), and various setup scripts for individual components (setupcontrol.sh, setupnode.sh, setupcluster.sh). The repository demonstrates solid DevOps engineering practices with idempotent scripts, proper error handling, and clear separation of concerns across different deployment stages.