You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
[+] updated README with detailed environment variable descriptions
[+] improved Kubernetes labels section for clarity
[+] added examples for service definitions with connection pooling
[+] modified connection string format section for better readability
[+] updated note regarding multi-node cluster setup
[+] enhanced error handling in main.go for KUBE_CONTEXT retrieval
[+] set default KUBE_CONTEXT to 'local-test' if not provided
| xdatabase-proxy-pooled | Whether this is a connection pooling service | true/false |
71
+
| xdatabase-proxy-destination-port | Target port for the database connection | 5432 |
72
72
73
73
> **Important**: This proxy is designed to be tool-agnostic. You don't need to use any specific pooling or cluster management solution. Simply add the appropriate labels to any service, and the proxy will route connections accordingly based on those labels.
74
74
@@ -77,11 +77,13 @@ The following labels are required for the proxy to identify database services:
77
77
The proxy supports three connection scenarios:
78
78
79
79
1.**Direct Connection**
80
+
80
81
- Client → PostgreSQL
81
82
- Simple, direct connection to a single PostgreSQL instance
82
83
- Use when connection pooling is not needed
83
84
84
85
2.**Connection Pooling**
86
+
85
87
- Client → Connection Pooler → PostgreSQL
86
88
- Efficient connection management
87
89
- Recommended for applications with many connections
@@ -98,6 +100,7 @@ The proxy supports three connection scenarios:
98
100
### Service Definition Examples
99
101
100
102
#### 1. Direct PostgreSQL Service
103
+
101
104
```yaml
102
105
apiVersion: v1
103
106
kind: Service
@@ -107,15 +110,16 @@ metadata:
107
110
xdatabase-proxy-enabled: "true"
108
111
xdatabase-proxy-deployment-id: "db-deployment-1"
109
112
xdatabase-proxy-database-type: "postgresql"
110
-
xdatabase-proxy-pooled: "false"# Direct PostgreSQL connection
111
-
xdatabase-proxy-destination-port: "5432"# Target PostgreSQL port
113
+
xdatabase-proxy-pooled: "false"# Direct PostgreSQL connection
114
+
xdatabase-proxy-destination-port: "5432"# Target PostgreSQL port
112
115
spec:
113
116
ports:
114
117
- port: 5432
115
118
name: postgresql
116
119
```
117
120
118
121
#### 2. Connection Pooling Service (Example with PgBouncer)
122
+
119
123
```yaml
120
124
apiVersion: v1
121
125
kind: Service
@@ -125,15 +129,16 @@ metadata:
125
129
xdatabase-proxy-enabled: "true"
126
130
xdatabase-proxy-deployment-id: "db-deployment-1"
127
131
xdatabase-proxy-database-type: "postgresql"
128
-
xdatabase-proxy-pooled: "true"# This indicates it's a connection pooling service
129
-
xdatabase-proxy-destination-port: "6432"# Target pooler port
132
+
xdatabase-proxy-pooled: "true"# This indicates it's a connection pooling service
133
+
xdatabase-proxy-destination-port: "6432"# Target pooler port
130
134
spec:
131
135
ports:
132
136
- port: 6432
133
137
name: postgresql
134
138
```
135
139
136
140
#### 3. Multi-Node Cluster Setup (Example with Pgpool-II)
141
+
137
142
```yaml
138
143
# Connection Pooler Service (Required for multi-node)
139
144
apiVersion: v1
@@ -144,35 +149,24 @@ metadata:
144
149
xdatabase-proxy-enabled: "true"
145
150
xdatabase-proxy-deployment-id: "db-deployment-1"
146
151
xdatabase-proxy-database-type: "postgresql"
147
-
xdatabase-proxy-pooled: "true"# Required for multi-node setup
152
+
xdatabase-proxy-pooled: "true"# Required for multi-node setup
153
+
xdatabase-proxy-destination-port: "6432"# Target cluster manager port (Same as the connection pooler port)
148
154
spec:
149
155
ports:
150
156
- port: 6432
151
157
name: postgresql
152
-
---
153
-
# Cluster Manager Service
154
-
apiVersion: v1
155
-
kind: Service
156
-
metadata:
157
-
name: cluster-manager
158
-
labels:
159
-
xdatabase-proxy-enabled: "true"
160
-
xdatabase-proxy-deployment-id: "db-deployment-1"
161
-
xdatabase-proxy-database-type: "postgresql"
162
-
xdatabase-proxy-pooled: "true"# Must be true for cluster manager
163
-
spec:
164
-
ports:
165
-
- port: 9999# Target port for your cluster manager
166
-
name: postgresql
167
158
```
168
159
160
+
> **Note:** For multi-node clusters (e.g., Pgpool-II, Patroni, etc.), you only need to define the connection pooler service as shown above. There is no need for a separate cluster manager service definition; the proxy will automatically handle routing based on labels.
0 commit comments