Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/farrajota/kubernetes-postgres-pgbouncer
Tutorial on how to setup a connection pool using pgbouncer for PostgreSQL
https://github.com/farrajota/kubernetes-postgres-pgbouncer
kubernetes kustomize pgbouncer postgres
Last synced: about 12 hours ago
JSON representation
Tutorial on how to setup a connection pool using pgbouncer for PostgreSQL
- Host: GitHub
- URL: https://github.com/farrajota/kubernetes-postgres-pgbouncer
- Owner: farrajota
- License: mit
- Created: 2020-07-12T20:48:08.000Z (over 4 years ago)
- Default Branch: master
- Last Pushed: 2020-08-21T22:29:26.000Z (about 4 years ago)
- Last Synced: 2023-10-20T12:34:52.184Z (about 1 year ago)
- Topics: kubernetes, kustomize, pgbouncer, postgres
- Language: Shell
- Homepage:
- Size: 11.7 KB
- Stars: 2
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Setting a connection pool using PgBouncer for PostgreSQL
Setting up a connection pool for PostgreSQL does not have to be a complicated process.
Actually, it can be a reasonably simple procedure if you know enough. In this repo you'll
find a simple tutorial on how to deploy PgBouncer alongside a Postgres database in a
kubernetes environment.> Note: This tutorial uses kustomize to configure and setup the deployment manifest.
If you never used it before, it is a [simple and powerful tool](https://kustomize.io/)
to customize kubernetes deployments.## Requirements
- kubernetes cluster (e.g., miniconda, k3s/k3d, kind)
- kubectl (1.16+ kustomize)
- Linux / MacOS# Setting up the environment / resources
1. Start the kubernetes cluster
```bash
minikube start
```2. Generate k8s deploy manifest
```bash
kubectl kustomize > deploy.yaml
```3. Create the k8s resources
```bash
kubectl create -f deploy.yaml
```4. Test the setup
```bash
kubectl -n database exec -it pg-0 -- bash -c 'PGPASSWORD=password_user1 psql -U user1 -h pgbouncer -p 5439 -d sandbox -c " SELECT * from test"'
```5. Destroy the k8s resources
```bash
kubectl delete -f deploy.yaml
```6. Clean remaining artifacts
```bash
rm deploy.yaml
```## References
- https://www.pgbouncer.org/config.html
- https://gitlab.com/aztek-io/oss/containers/pgbouncer-container
- https://www.cybertec-postgresql.com/en/pgbouncer-authentication-made-easy/
- https://www.depesz.com/2012/12/02/what-is-the-point-of-bouncing/
- https://www.enterprisedb.com/postgres-tutorials/challenges-setting-maxconnections-and-why-you-should-use-connection-pooler# License
[MIT License](LICENSE)