Skip to content

Commit 3f71d92

Browse files
committed
chore: add ability to set public service lb
1 parent 7df0719 commit 3f71d92

File tree

4 files changed

+53
-3
lines changed

4 files changed

+53
-3
lines changed

pgbouncer/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,4 @@ apiVersion: v1
22
appVersion: "1.18.0"
33
description: A Helm chart installing pgbouncer in kubernetes
44
name: pgbouncer
5-
version: 1.11.0
5+
version: 1.12.0
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
{{- if .Values.servicePublic.enabled }}
2+
{{- $suffix := default "public" .Values.servicePublic.nameSuffix }}
3+
{{- $derivedName := printf "%s-%s" (include "pgbouncer.fullname" .) $suffix }}
4+
{{- $serviceName := default $derivedName .Values.servicePublic.nameOverride | trunc 63 | trimSuffix "-" }}
5+
apiVersion: v1
6+
kind: Service
7+
metadata:
8+
name: {{ $serviceName }}
9+
labels:
10+
app.kubernetes.io/name: {{ template "pgbouncer.name" . }}
11+
helm.sh/chart: {{ template "pgbouncer.chart" . }}
12+
app.kubernetes.io/instance: {{ .Release.Name }}
13+
app.kubernetes.io/managed-by: {{ .Release.Service }}
14+
{{- if .Values.servicePublic.annotations }}
15+
annotations:
16+
{{- toYaml .Values.servicePublic.annotations | nindent 4 }}
17+
{{- end }}
18+
spec:
19+
type: {{ default "LoadBalancer" .Values.servicePublic.type }}
20+
{{- if .Values.servicePublic.externalTrafficPolicy }}
21+
externalTrafficPolicy: {{ .Values.servicePublic.externalTrafficPolicy }}
22+
{{- end }}
23+
{{- if .Values.servicePublic.loadBalancerSourceRanges }}
24+
loadBalancerSourceRanges:
25+
{{- toYaml .Values.servicePublic.loadBalancerSourceRanges | nindent 4 }}
26+
{{- end }}
27+
ports:
28+
- port: {{ .Values.servicePublic.port }}
29+
targetPort: psql
30+
protocol: TCP
31+
name: psql
32+
{{- if .Values.servicePublic.nodePort }}
33+
nodePort: {{ .Values.servicePublic.nodePort }}
34+
{{- end }}
35+
selector:
36+
app.kubernetes.io/name: {{ template "pgbouncer.name" . }}
37+
app.kubernetes.io/instance: {{ .Release.Name }}
38+
{{- end }}

pgbouncer/templates/service.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ metadata:
88
app.kubernetes.io/instance: {{ .Release.Name }}
99
app.kubernetes.io/managed-by: {{ .Release.Service }}
1010
{{- if .Values.service.annotations }}
11-
annotations:
11+
annotations:
1212
{{- toYaml .Values.service.annotations | nindent 4 }}
1313
{{- end }}
1414
spec:

pgbouncer/values.yaml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,11 +89,23 @@ image:
8989
service:
9090
type: ClusterIP
9191
port: 5432
92+
annotations: {}
93+
loadBalancerSourceRanges: []
9294
# Set to local if want to preserve source IP for NodePort or LoadBalancer
9395
# externalTrafficPolicy: Cluster
9496
# nodePort: 30543 # when type NodePort
97+
98+
## Optional second Service (e.g., internet-facing LoadBalancer)
99+
servicePublic:
100+
enabled: false
101+
nameSuffix: public
102+
type: LoadBalancer
103+
port: 5432
95104
annotations: {}
96105
loadBalancerSourceRanges: []
106+
# Set to local if want to preserve source IP for NodePort or LoadBalancer
107+
# externalTrafficPolicy: Local
108+
# nodePort: 30543 # when type NodePort
97109

98110
## Labels to add to the pod metadata
99111
##
@@ -260,4 +272,4 @@ serviceAccount:
260272
name: ""
261273
## Annotations for created ServiceAccount
262274
##
263-
annotations: {}
275+
annotations: {}

0 commit comments

Comments
 (0)