-
Notifications
You must be signed in to change notification settings - Fork 0
/
postgres-deployment.yml
102 lines (98 loc) · 2.52 KB
/
postgres-deployment.yml
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
apiVersion: v1
kind: Service
metadata:
namespace: ngcovid
name: ngcovid-db
spec:
ports:
- port: 5432
selector:
app: postgres-db
---
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv-volume
labels:
type: local
spec:
storageClassName: manual
capacity:
storage: 3Gi
accessModes:
- ReadWriteOnce
hostPath:
path: "/home/vagrant/dbdata"
---
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: postgres-pv-claim
namespace: ngcovid
spec:
storageClassName: manual
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 1Gi
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: ngcovid-db
namespace: ngcovid
spec:
selector:
matchLabels:
app: postgres-db
strategy:
type: Recreate
template:
metadata:
labels:
app: postgres-db
spec:
containers:
- image: postgres
name: postgres-db
env:
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: postgres-secrets
key: password
- name: POSTGRES_USER
valueFrom:
configMapKeyRef:
name: postgresconfig
key: postgresuser
- name: POSTGRES_DB
valueFrom:
configMapKeyRef:
name: postgresconfig
key: postgresdb
- name: PGDATA
value: /var/lib/postgresql/data/pgdata
ports:
- containerPort: 5432
volumeMounts:
- name: postgres-persistent-storage
mountPath: /var/lib/postgresql/data
subPath: datadir
- name: postgres-persistent-storage
mountPath: /docker-entrypoint-initdb.d
subPath: initdir
initContainers:
- name: initializedir
image: busybox
command: ["/bin/sh", "-c"]
args: ["wget -O /docker-entrypoint-initdb.d/db-restore.sql https://raw.githubusercontent.com/seyio91/scraper-app-dev/master/db-ncdc-restore.sql; /bin/chmod -R 777 /docker-entrypoint-initdb.d/"]
volumeMounts:
- name: postgres-persistent-storage
mountPath: /docker-entrypoint-initdb.d
subPath: initdir
volumes:
- name: postgres-persistent-storage
persistentVolumeClaim:
claimName: postgres-pv-claim