-
Notifications
You must be signed in to change notification settings - Fork 13
/
postgres-cleanup.yaml
35 lines (35 loc) · 997 Bytes
/
postgres-cleanup.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
apiVersion: batch/v1
kind: CronJob
metadata:
name: postgresdb-cleanup
spec:
successfulJobsHistoryLimit: 5
schedule: "*/2 * * * *"
jobTemplate:
spec:
template:
spec:
containers:
- image: postgres
name: postgresdb-cleanup
command:
- bash
- -c
- cd && echo "*:*:*:*:$PGPASS" > .pgpass && chmod 600 .pgpass && psql --host=postgresdb --command="delete from todo"
env:
- name: PGUSER
valueFrom:
secretKeyRef:
name: db-security
key: db.user.name
- name: PGPASS
valueFrom:
secretKeyRef:
name: db-security
key: db.user.password
- name: PGDATABASE
valueFrom:
configMapKeyRef:
name: postgres-config
key: postgres.db.name
restartPolicy: OnFailure