-
Notifications
You must be signed in to change notification settings - Fork 90
Expand file tree
/
Copy pathseed-job.yaml
More file actions
75 lines (74 loc) · 2.16 KB
/
seed-job.yaml
File metadata and controls
75 lines (74 loc) · 2.16 KB
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
apiVersion: v1
kind: ConfigMap
metadata:
name: postgresql-sample-sql
labels:
app: postgresql-sample
data:
setup.sql: |-
CREATE TABLE IF NOT EXISTS orders (
order_id varchar(50) PRIMARY KEY,
description varchar(255),
created timestamptz DEFAULT NOW()
);
INSERT INTO orders (order_id, description) VALUES
('10000001', 'Sample Order 1'),
('10000002', 'Sample Order 2')
ON CONFLICT (order_id) DO NOTHING;
---
apiVersion: batch/v1
kind: Job
metadata:
name: seed-postgresql
labels:
app: postgresql-sample
spec:
backoffLimit: 1
template:
spec:
restartPolicy: Never
containers:
- name: psql-client
image: postgres:15
env:
- name: PGHOST
valueFrom:
secretKeyRef:
name: postgres-binding # change to your binding Secret name
key: hostname
- name: PGPORT
valueFrom:
secretKeyRef:
name: postgres-binding # change to your binding Secret name
key: port
- name: PGDATABASE
valueFrom:
secretKeyRef:
name: postgres-binding # change to your binding Secret name
key: dbname
- name: PGUSER
valueFrom:
secretKeyRef:
name: postgres-binding # change to your binding Secret name
key: username
- name: PGPASSWORD
valueFrom:
secretKeyRef:
name: postgres-binding # change to your binding Secret name
key: password
- name: PGSSLMODE
valueFrom:
secretKeyRef:
name: postgres-binding # change to your binding Secret name
key: sslmode
optional: true
volumeMounts:
- name: sql
mountPath: /init
command: ["psql"]
args:
["-v", "ON_ERROR_STOP=1", "-f", "/init/setup.sql"]
volumes:
- name: sql
configMap:
name: postgresql-sample-sql