-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathhass-db.yaml
127 lines (103 loc) · 2.41 KB
/
hass-db.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
kind: ConfigMap
apiVersion: v1
metadata:
name: root-crontab
namespace: {{namespace}}
data:
root: |
# do daily/weekly/monthly maintenance
# min hour day month weekday command
*/5 * * * * /usr/local/bin/psql -U hass -c "call pwpl_update_event_table_cron();"
*/15 * * * * run-parts /etc/periodic/15min
0 * * * * run-parts /etc/periodic/hourly
0 2 * * * run-parts /etc/periodic/daily
0 3 * * 6 run-parts /etc/periodic/weekly
0 5 1 * * run-parts /etc/periodic/monthly
---
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: hass-database
namespace: {{namespace}}
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 20Gi
storageClassName: microk8s-hostpath
---
apiVersion: v1
kind: Secret
metadata:
name: hass-database
namespace: {{namespace}}
type: Opaque
stringData:
POSTGRES_HOST: database
POSTGRES_DB: hass
POSTGRES_USER: hass
POSTGRES_PASSWORD: hassuspwd
---
apiVersion: apps/v1
kind: ReplicaSet
metadata:
name: tsdb
namespace: {{namespace}}
labels:
app: tsdb
spec:
replicas: 1
selector:
matchLabels:
app: tsdb
template:
metadata:
labels:
app: tsdb
spec:
containers:
- name: tsdb
image: docker.io/timescale/timescaledb:latest-pg15
envFrom:
- secretRef:
name: hass-database
ports:
- containerPort: 5432
volumeMounts:
- name: hass-database
mountPath: /var/lib/postgresql/data
- name: root-crontab
mountPath: /etc/crontabs/root
subPath: root
- name: dshm
mountPath: /dev/shm
lifecycle:
postStart:
exec:
command: ['/usr/sbin/crond']
volumes:
- name: hass-database
persistentVolumeClaim:
claimName: hass-database
- name: root-crontab
configMap:
name: root-crontab
- name: dshm
emptyDir:
medium: Memory
---
apiVersion: v1
kind: Service
metadata:
name: database
namespace: {{namespace}}
spec:
type: NodePort
selector:
app: tsdb
ports:
- protocol: TCP
nodePort: 30021
port: 5432
targetPort: 5432