forked from karlkfi/kubexit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathjob.yaml
94 lines (94 loc) · 2.53 KB
/
job.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
apiVersion: batch/v1
kind: Job
metadata:
name: example-job
spec:
backoffLimit: 1
template:
metadata:
labels:
app: example-job
spec:
restartPolicy: Never
volumes:
- name: graveyard
emptyDir:
medium: Memory
- name: cloudsql
emptyDir: {}
- name: service-account-token
secret:
secretName: service-account-token
containers:
- name: psql
image: postgresql-client
command: ['kubexit', 'psql']
args: ['-c', 'SELECT * FROM foo;']
env:
- name: KUBEXIT_NAME
value: psql
- name: KUBEXIT_GRAVEYARD
value: /graveyard
- name: KUBEXIT_BIRTH_DEPS
value: cloudsql-proxy
- name: KUBEXIT_POD_NAME
valueFrom:
fieldRef:
fieldPath: metadata.name
- name: KUBEXIT_NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: PGDATABASE
# ex: postgres://user:pass@localhost:5432/db?sslmode=disable
valueFrom:
secretKeyRef:
name: postgres-database
key: url
volumeMounts:
- mountPath: /graveyard
name: graveyard
- name: cloudsql-proxy
image: cloudsql-proxy-kubexit
command: ['kubexit', 'cloud_sql_proxy', '-term_timeout=10s']
lifecycle:
preStop:
exec:
command: ['sleep', '10']
env:
- name: INSTANCES
value: project:region:instance=tcp:localhost:5432
- name: GOOGLE_APPLICATION_CREDENTIALS
value: /credentials/credentials.json
- name: KUBEXIT_NAME
value: cloudsql-proxy
- name: KUBEXIT_GRAVEYARD
value: /graveyard
- name: KUBEXIT_DEATH_DEPS
value: psql
ports:
- name: proxy
containerPort: 5432
volumeMounts:
- mountPath: /cloudsql
name: cloudsql
- mountPath: /credentials
name: service-account-token
- mountPath: /graveyard
name: graveyard
livenessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 30
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 6
readinessProbe:
tcpSocket:
port: 5432
initialDelaySeconds: 5
periodSeconds: 10
timeoutSeconds: 5
successThreshold: 1
failureThreshold: 6