A Kubernetes-native PostgreSQL endpoint management tool for Wire that automatically discovers and manages PostgreSQL cluster topology, updating Kubernetes services to point to the correct read-write and read-only endpoints.
- Kubernetes: v1.29+ (requires kubernetes client v30.0.0+)
- Python: 3.9+
- PostgreSQL: Compatible with psycopg 3.2+
psycopg>=3.2.0- PostgreSQL database adapterstructlog>=24.0.0- Structured loggingkubernetes>=30.0.0- Kubernetes Python client
# Pull the latest image
docker pull sukisuk/postgres-endpoint-manager:latest
# Run the container
docker run --rm sukisuk/postgres-endpoint-manager:latest --help# Clone the repository
git clone https://github.com/wireapp/postgres-endpoint-manager.git
cd postgres-endpoint-manager
# Install dependencies
pip install -r requirements.txt
# Run tests
python -m pytest tests/For the latest changes and release notes, see the Changelog.
The application requires the following environment variables:
PG_NODES: Comma-separated list of PostgreSQL node IP addresses/hostnamesNAMESPACE: Kubernetes namespace (default:default)
RW_SERVICE: Read-write service name (default:{CHART_NAME}-rw)RO_SERVICE: Read-only service name (default:{CHART_NAME}-ro)PGUSER: PostgreSQL username (default:repmgr)PGPASSWORD: PostgreSQL password (default:securepassword)PGDATABASE: PostgreSQL database name (default:repmgr)PGCONNECT_TIMEOUT: Connection timeout in seconds (default:5)PGPORT: PostgreSQL port (default:5432)PGSSLMODE: SSL mode for connections (default: empty)TCP_CONNECT_TIMEOUT: TCP connection timeout (default:1.0)MAX_WORKERS: Maximum worker threads (default:3)CHART_NAME: Helm release name for service naming (default:postgres-external)
# Build Docker image
make build-pg-manager
# Build for multiple platforms
make build-pg-manager-multi
# Run tests
make test-pg-manager
# Push to registry
make push-pg-managerThe project includes comprehensive test scenarios:
# Run all tests
make test-pg-manager
# Test with custom configuration
make test-pg-manager-custom
# Interactive testing
make test-pg-manager-interactiveCreate a semantic version tag to trigger automated release:
git tag v1.0.0
git push origin v1.0.0This will build and push images with tags: 1.0.0, 1.0, 1, latest
The PostgreSQL Endpoint Manager consists of several key components:
- Orchestrator: Main coordination logic
- KubeClient: Kubernetes API interactions
- PostgresChecker: Database connectivity and health checks
- TopologyVerifier: Cluster topology validation
- EndpointUpdater: Kubernetes service endpoint management
For a detailed visual representation of the application flow, see the Communication Flow Diagram.
- Container Entrypoint - Detailed information about the container structure, entrypoint flow, and package organization
- Communication Flow - Mermaid diagram showing the complete application flow from startup to endpoint updates
- CI/CD Pipeline - Comprehensive guide to the CI pipeline, runtime vs test images, and debugging workflows
- Changelog - Complete history of changes and releases
This project is licensed under the Apache License 2.0 - see the LICENSE file for details.