forked from awslabs/pgbouncer-fast-switchover
-
Notifications
You must be signed in to change notification settings - Fork 0
/
pgbouncer-deploy.yaml
121 lines (121 loc) · 2.66 KB
/
pgbouncer-deploy.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
kind: ClusterRole
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: adaptivepgbouncer
namespace: default
rules:
- apiGroups:
- ""
resources:
- "*"
verbs:
- "*"
- apiGroups:
- rbac.authorization.k8s.io
- extensions
- apps
resources:
- "*"
verbs:
- "*"
- apiGroups:
- apiextensions.k8s.io
resources:
- customresourcedefinitions
- pods
- deployments
verbs:
- get
- list
- watch
- create
- delete
---
apiVersion: v1
kind: ServiceAccount
metadata:
name: adaptivepgbouncer
---
kind: ClusterRoleBinding
apiVersion: rbac.authorization.k8s.io/v1
metadata:
name: adaptivepgbouncer
namespace: default
subjects:
- kind: ServiceAccount
name: adaptivepgbouncer
namespace: default
roleRef:
kind: ClusterRole
name: adaptivepgbouncer
apiGroup: rbac.authorization.k8s.io
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: pgbouncer
namespace: default
labels:
app: pgbouncer
spec:
strategy:
rollingUpdate:
maxUnavailable: 10
selector:
matchLabels:
app: pgbouncer
template:
metadata:
labels:
app: pgbouncer
spec:
nodeSelector:
karpenter.sh/provisioner-name: default
serviceAccountName: adaptivepgbouncer
containers:
- name: pgbouncer
image: ${AWS_ACCOUNT_ID}.dkr.ecr.us-west-2.amazonaws.com/pgbouncer:1.15.0amzn2.aarch64
imagePullPolicy: Always
ports:
- containerPort: 5432
resources:
requests:
cpu: 512m
memory: 512Mi
limits:
cpu: 512m
memory: 512Mi
envFrom:
- secretRef:
name: pgbouncer
env:
- name: default_pool_size
value: "20"
- name: log_connections
value: "1"
- name: log_disconnections
value: "1"
- name: log_pooler_errors
value: "1"
- name: log_stats
value: "1"
- name: routing_rules_py_module_file
value: "/home/pgbouncer/routing_rules.py"
- name: PGB_LISTEN_PORT
value: "5432"
- name: PGB_LISTEN_ADDR
value: "0.0.0.0"
- name: POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
livenessProbe:
tcpSocket:
port: 5432
periodSeconds: 60
lifecycle:
preStop:
exec:
# Allow existing queries clients to complete within 120 seconds
command: ["/bin/sh", "-c", "killall -INT pgbouncer && sleep 120"]