-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworkers-deployment.yaml
120 lines (112 loc) · 4.02 KB
/
workers-deployment.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
apiVersion: v1
kind: Service
metadata:
name: citus-workers
labels:
app: citus-workers
spec:
ports:
- port: 5432
name: postgres
clusterIP: None
selector:
app: citus-workers
---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: citus-workers
spec:
serviceName: "citus-workers"
replicas: 3
selector:
matchLabels:
app: citus-workers
template:
metadata:
labels:
app: citus-workers
spec:
affinity:
podAntiAffinity:
requiredDuringSchedulingIgnoredDuringExecution:
- labelSelector:
matchExpressions:
- key: "app"
operator: In
values:
- citus-workers
- citus-coordinator
topologyKey: "kubernetes.io/hostname"
containers:
- name: mobilitydb-cloud
#image: bouzouidja/mobilitydb-cloud:latest
image: europe-west1-docker.pkg.dev/distributed-postgresql-82971/sidahmed-gcp-registry/mobilitydb-cloud
imagePullPolicy: "IfNotPresent"
args:
- -c
- max_locks_per_transaction=128
- -c
- shared_preload_libraries=citus, postgis-3.so
- -c
- wal_level=logical
ports:
- containerPort: 5432
#resources:
# limits:
# cpu: 3500m
# memory: 14G
# requests:
# cpu: 3000m
# memory: 12G
lifecycle:
postStart:
exec:
command:
- /bin/sh
- -c
- |
sleep 9
psql -U $POSTGRES_USER -d $POSTGRES_DB --command="CREATE EXTENSION IF NOT EXISTS citus; CREATE EXTENSION IF NOT EXISTS hstore; CREATE EXTENSION IF NOT EXISTS mobilitydb cascade; CREATE EXTENSION IF NOT EXISTS pgrouting;"
psql -h citus-coordinator -U $POSTGRES_USER -d $POSTGRES_DB --command="SELECT * from citus_add_node('$POD_IP', 5432) where NOT EXISTS (SELECT pod_ip FROM pod_information WHERE pod_ip = '$POD_IP');"
psql -h citus-coordinator -U $POSTGRES_USER -d $POSTGRES_DB --command="INSERT INTO pod_information(pod_ip, nodeid, nodeport, pod_hostname ) SELECT nodename, nodeid, nodeport, '${HOSTNAME}' FROM pg_dist_node WHERE nodename = '$POD_IP' and NOT EXISTS (SELECT pod_ip FROM pod_information WHERE pod_ip = '$POD_IP') and NOT EXISTS (SELECT pod_hostname FROM pod_information WHERE pod_hostname = '${HOSTNAME}');"
psql -h citus-coordinator -U $POSTGRES_USER -d $POSTGRES_DB --command="select citus_update_node((select nodeid from pod_information where pod_hostname='${HOSTNAME}'),'$POD_IP', 5432) from pg_dist_node where nodename =(select pod_ip from pod_information where pod_hostname='${HOSTNAME}'); UPDATE pod_information SET pod_ip = '$POD_IP' WHERE nodeid = (select nodeid from pod_information where pod_hostname='${HOSTNAME}');"
env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_USER
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_PASSWORD
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_PASSWORD
- name: POSTGRES_DB
valueFrom:
secretKeyRef:
name: postgres-secret
key: POSTGRES_DB
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
- name: POD_IP
valueFrom:
fieldRef:
fieldPath: status.podIP
volumeMounts:
- mountPath: /var/lib/postgresql/data
name: postgres-pv-claim-worker
volumeClaimTemplates:
- metadata:
name: postgres-pv-claim-worker
spec:
accessModes: [ "ReadWriteOnce" ]
storageClassName: "standard-rwo"
resources:
requests:
storage: 8Gi