-
Notifications
You must be signed in to change notification settings - Fork 0
/
template.yml
289 lines (289 loc) · 7.47 KB
/
template.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
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
kind: Template
apiVersion: template.openshift.io/v1
parameters:
- name: BRANCH
required: true
- name: APP
required: true
value: finbif2gbif
- name: PAGE_TITLE
required: true
value: "FinBIF to GBIF"
- name: APP_PORT
required: true
value: "8000"
- name: STORAGE_CLASS
required: true
value: standard-csi
- name: ACCESS_MODE
required: true
value: ReadWriteOnce
- name: HEALTH
required: true
value: /healthz
- name: LIVENESS_PERIOD
required: true
value: "30"
- name: FAILURE_THRESHOLD
required: true
value: "5"
- name: READINESS_PERIOD
required: true
value: "5"
- name: HOST
required: true
- name: FINBIF_API
required: true
- name: FINBIF_ACCESS_TOKEN
required: true
- name: GBIF_USER
required: true
- name: GBIF_ORG
required: true
- name: GBIF_INSTALLATION
required: true
- name: GBIF_PASS
required: true
- name: GBIF_API
required: true
- name: SMTP_SERVER
required: true
- name: SMTP_PORT
required: true
- name: ERROR_EMAIL_TO
required: true
- name: ERROR_EMAIL_FROM
required: true
- name: STORAGE
required: true
- name: JOB_SECRET
required: true
- name: RCLONE_ACCESS_KEY_ID
required: true
- name: RCLONE_SECRET_ACCESS_KEY
required: true
metadata:
name: ${APP}
objects:
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: ${APP}-${BRANCH}
spec:
storageClassName: ${STORAGE_CLASS}
accessModes:
- ${ACCESS_MODE}
resources:
requests:
storage: ${STORAGE}
- kind: Secret
apiVersion: v1
metadata:
name: ${APP}-${BRANCH}
type: Opaque
data:
finbif_api: ${FINBIF_API}
finbif_access_token: ${FINBIF_ACCESS_TOKEN}
gbif_api: ${GBIF_API}
gbif_user: ${GBIF_USER}
gbif_org: ${GBIF_ORG}
gbif_installation: ${GBIF_INSTALLATION}
gbif_pass: ${GBIF_PASS}
job_secret: ${JOB_SECRET}
rclone_access_key_id: ${RCLONE_ACCESS_KEY_ID}
rclone_secret_access_key: ${RCLONE_SECRET_ACCESS_KEY}
- kind: Deployment
apiVersion: apps/v1
metadata:
name: ${APP}-${BRANCH}
labels:
app: ${APP}
spec:
replicas: 1
selector:
matchLabels:
app: ${APP}
strategy:
type: Recreate
template:
metadata:
labels:
app: ${APP}
branch: ${BRANCH}
spec:
containers:
- image: ghcr.io/luomus/${APP}:${BRANCH}
imagePullPolicy: Always
name: ${APP}-${BRANCH}
ports:
- containerPort: ${{APP_PORT}}
volumeMounts:
- mountPath: /home/user/var
name: ${APP}-${BRANCH}
startupProbe:
httpGet:
path: ${HEALTH}
port: ${{APP_PORT}}
failureThreshold: ${{FAILURE_THRESHOLD}}
periodSeconds: ${{LIVENESS_PERIOD}}
livenessProbe:
httpGet:
path: ${HEALTH}
port: ${{APP_PORT}}
failureThreshold: ${{FAILURE_THRESHOLD}}
periodSeconds: ${{LIVENESS_PERIOD}}
readinessProbe:
httpGet:
path: ${HEALTH}
port: ${{APP_PORT}}
periodSeconds: ${{READINESS_PERIOD}}
env:
- name: PAGE_TITLE
value: ${PAGE_TITLE}
- name: ENDPOINTS
value: https://${HOST}
- name: FINBIF_USER_AGENT
value: https://github.com/luomus/${APP}.git
- name: STATUS_DIR
value: var/status
- name: LOG_DIR
value: var/logs
- name: FINBIF_ACCESS_TOKEN
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: finbif_access_token
- name: FINBIF_API
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: finbif_api
- name: GBIF_USER
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: gbif_user
- name: GBIF_ORG
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: gbif_org
- name: GBIF_INSTALLATION
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: gbif_installation
- name: GBIF_PASS
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: gbif_pass
- name: GBIF_API
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: gbif_api
- name: JOB_SECRET
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: job_secret
- name: RCLONE_CONFIG_DEFAULT_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: rclone_access_key_id
- name: RCLONE_CONFIG_DEFAULT_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: rclone_secret_access_key
- name: BRANCH
value: ${BRANCH}
- name: SMTP_SERVER
value: ${SMTP_SERVER}
- name: SMTP_PORT
value: ${SMTP_PORT}
- name: ERROR_EMAIL_TO
value: ${ERROR_EMAIL_TO}
- name: ERROR_EMAIL_FROM
value: ${ERROR_EMAIL_FROM}
resources:
limits:
cpu: "1000m"
memory: "5Gi"
volumes:
- name: ${APP}-${BRANCH}
persistentVolumeClaim:
claimName: ${APP}-${BRANCH}
- kind: Service
apiVersion: v1
metadata:
name: ${APP}-${BRANCH}
labels:
app: ${APP}
spec:
ports:
- name: ${APP_PORT}
port: ${{APP_PORT}}
targetPort: ${{APP_PORT}}
selector:
app: ${APP}
branch: ${BRANCH}
- kind: Route
apiVersion: v1
metadata:
name: ${APP}-${BRANCH}
labels:
app: ${APP}
spec:
host: ${HOST}
port:
targetPort: ${{APP_PORT}}
tls:
insecureEdgeTerminationPolicy: Redirect
to:
kind: Service
name: ${APP}-${BRANCH}
wildcardPolicy: None
- kind: CronJob
apiVersion: batch/v1
metadata:
name: ${APP}-${BRANCH}
spec:
schedule: "0 20 * * *"
concurrencyPolicy: "Forbid"
successfulJobsHistoryLimit: 1
failedJobsHistoryLimit: 3
jobTemplate:
spec:
template:
metadata:
labels:
app: ${APP}
spec:
containers:
- name: ${APP}-${BRANCH}
# docker manifest inspect docker.io/redhat/ubi9:9.4 -v | jq '.[0].Descriptor.digest'
image: docker.io/redhat/ubi9:9.4@sha256:b8a991d0c5d0184d76196caf11ddc0605714c65f7a06ad23ad72e3d0a723eee1
command:
- 'sh'
- '-c'
- >-
curl -s -w '%{stderr} Code: %{response_code} URL: %{url_effective}\n'
$APP_HOSTNAME:$APP_PORT/job?secret=$JOB_SECRET
env:
- name: JOB_SECRET
valueFrom:
secretKeyRef:
name: ${APP}-${BRANCH}
key: job_secret
- name: APP_HOSTNAME
value: ${APP}-${BRANCH}
- name: APP_PORT
value: ${APP_PORT}
resources:
limits:
cpu: "100m"
memory: "100Mi"
restartPolicy: Never