-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
template-external-postgresql.yml
325 lines (325 loc) · 8.76 KB
/
template-external-postgresql.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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
kind: Template
apiVersion: v1
labels:
app: weblate
part-of: weblate-on-premise
template: weblate-on-premise
metadata:
name: weblate
annotations:
openshift.io/display-name: Weblate (Persistent / PostgreSQL)
openshift.io/documentation-url: https://github.com/WeblateOrg/weblate
description: >-
Creates a Weblate installation with separate PostgreSQL database instance.
Requires that two persistent volumes be available. If a ReadWriteMany
persistent volume type is available and used, Weblate can be scaled to
multiple replicas and the deployment strategy switched to Rolling to
permit rolling deployments on restarts.
tags: quickstart,python,weblate,localization,translation
iconClass: icon-python
parameters:
- name: APPLICATION_NAME
description: The name of the Weblate instance.
value: weblate
from: '[a-zA-Z0-9]'
required: true
- name: WEBLATE_VERSION
description: >-
Weblate docker image version (see:
https://hub.docker.com/r/weblate/weblate/tags)
value: latest
required: true
- name: WEBLATE_VOLUME_SIZE
description: Size of the persistent volume for Weblate.
value: 10Gi
required: true
- name: WEBLATE_VOLUME_TYPE
description: Type of the persistent volume for Weblate.
value: ReadWriteOnce
required: true
- name: WEBLATE_DEPLOYMENT_STRATEGY
description: Type of the deployment strategy for Weblate.
value: Recreate
required: true
- name: WEBLATE_CPU_LIMIT
description: Amount of cpu cores available to Weblate.
value: '4'
required: true
- name: WEBLATE_MEMORY_LIMIT
description: Amount of memory available to Weblate.
value: 8Gi
required: true
- name: WEBLATE_ADMIN_PASSWORD
description: Password of the initial admin user.
from: '[a-zA-Z0-9]{12}'
generate: expression
- name: WEBLATE_ADMIN_EMAIL
description: Email address of the initial admin user.
value: [email protected]
required: true
- name: WEBLATE_SERVER_EMAIL
description: Email address for outgoing emails.
value: [email protected]
required: true
- name: WEBLATE_SITE_DOMAIN
displayName: Weblate Domain
description: >-
Domain of the application. The hostname can't be changed after the route
is created.
value: weblate.app-openshift.example.com
required: true
- name: CACHE_VOLUME_SIZE
description: Size of the persistent volume for Redis Cache.
value: 10Gi
required: true
- name: DATABASE_HOST
description: The hostname of the database user.
value: weblate
required: true
- name: DATABASE_PORT
description: The hostname of the database user.
value: 5432
required: true
- name: DATABASE_USERNAME
description: The name of the database user.
value: weblate
required: true
- name: DATABASE_PASSWORD
description: The password for the database user.
from: '[a-zA-Z0-9]{12}'
generate: expression
required: true
- name: REDIS_IMAGE
description: Link to the Redis Cache image.
value: docker-registry.default.svc:5000/openshift/redis:3.2
required: true
- name: REDIS_PASSWORD
description: Password for the Redis connection user.
from: '[a-zA-Z0-9]{16}'
generate: expression
required: true
objects:
- kind: DeploymentConfig
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}-web
labels:
component: web
spec:
strategy:
type: ${WEBLATE_DEPLOYMENT_STRATEGY}
triggers:
- type: ConfigChange
replicas: 1
selector:
org.weblate.service: ${APPLICATION_NAME}-web
template:
metadata:
labels:
component: web
org.weblate.service: ${APPLICATION_NAME}-web
spec:
initContainers:
- name: init-redis
image: busybox:1.28.4
env:
- name: REDIS_HOST
value: ${APPLICATION_NAME}-cache
command:
- sh
- -c
- >-
until nslookup $(REDIS_HOST); do echo waiting for redis; sleep
2; done;
volumes:
- name: data
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-weblate-data
containers:
- name: weblate-web
image: weblate/weblate:${WEBLATE_VERSION}
imagePullPolicy: Always
ports:
- containerPort: 8080
protocol: TCP
resources:
limits:
cpu: ${WEBLATE_CPU_LIMIT}
memory: ${WEBLATE_MEMORY_LIMIT}
requests:
cpu: 100m
memory: 2Gi
env:
- name: POSTGRES_DATABASE
value: weblate
- name: POSTGRES_HOST
value: ${APPLICATION_NAME}-postgresql
- name: POSTGRES_PORT
value: '5432'
- name: REDIS_HOST
value: ${APPLICATION_NAME}-cache
- name: REDIS_PORT
value: '6379'
envFrom:
- secretRef:
name: weblate-secret
- configMapRef:
name: weblate-config
volumeMounts:
- name: data
mountPath: /app/data
- kind: DeploymentConfig
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}-cache
labels:
component: redis
org.weblate.service: ${APPLICATION_NAME}-cache
spec:
strategy:
type: Recreate
triggers:
- type: ConfigChange
replicas: 1
selector:
org.weblate.service: ${APPLICATION_NAME}-cache
template:
metadata:
labels:
org.weblate.service: ${APPLICATION_NAME}-cache
spec:
volumes:
- name: data
persistentVolumeClaim:
claimName: ${APPLICATION_NAME}-redis-data
containers:
- name: redis
image: ${REDIS_IMAGE}
imagePullPolicy: IfNotPresent
ports:
- containerPort: 6379
protocol: TCP
livenessProbe:
timeoutSeconds: 1
initialDelaySeconds: 30
tcpSocket:
port: 6379
readinessProbe:
exec:
command:
- /bin/sh
- -i
- -c
- >-
test "$(redis-cli -h 127.0.0.1 -a $REDIS_PASSWORD ping)"
== "PONG"
failureThreshold: 3
initialDelaySeconds: 5
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
volumeMounts:
- name: data
mountPath: /var/lib/redis/data
capabilities: {}
env:
- name: REDIS_PASSWORD
valueFrom:
secretKeyRef:
key: REDIS_PASSWORD
name: ${APPLICATION_NAME}-secret
- kind: ConfigMap
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}-config
data:
WEBLATE_DEBUG: '0'
WEBLATE_SERVER_EMAIL: ${WEBLATE_SERVER_EMAIL}
WEBLATE_DEFAULT_FROM_EMAIL: ${WEBLATE_SERVER_EMAIL}
WEBLATE_SITE_DOMAIN: ${WEBLATE_SITE_DOMAIN}
- kind: Secret
apiVersion: v1
metadata:
annotations:
template.openshift.io/expose-password: "{.data['redis-password']}"
name: ${APPLICATION_NAME}-secret
stringData:
POSTGRES_PASSWORD: ${DATABASE_PASSWORD}
POSTGRES_USER: ${DATABASE_USERNAME}
POSTGRES_HOST: ${DATABASE_HOST}
POSTGRES_PORT: ${DATABASE_PORT}
REDIS_PASSWORD: ${REDIS_PASSWORD}
WEBLATE_ADMIN_PASSWORD: ${WEBLATE_ADMIN_PASSWORD}
WEBLATE_ADMIN_NAME: ${WEBLATE_ADMIN_EMAIL}
WEBLATE_ADMIN_EMAIL: ${WEBLATE_ADMIN_EMAIL}
- kind: Service
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}
labels:
app: ${APPLICATION_NAME}
spec:
ports:
- name: 8080-tcp
protocol: TCP
port: 8080
targetPort: 8080
selector:
org.weblate.service: ${APPLICATION_NAME}-web
- kind: Service
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}-cache
labels:
org.weblate.service: ${APPLICATION_NAME}-cache
spec:
ports:
- name: 6379-tcp
protocol: TCP
port: 6379
targetPort: 6379
selector:
org.weblate.service: ${APPLICATION_NAME}-cache
- kind: Route
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}
labels:
app: ${APPLICATION_NAME}
spec:
host: ${WEBLATE_SITE_DOMAIN}
to:
kind: Service
name: ${APPLICATION_NAME}
weight: 100
port:
targetPort: 8080
tls:
termination: edge
insecureEdgeTerminationPolicy: Allow
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}-redis-data
labels:
app: ${APPLICATION_NAME}
allowVolumeExpansion: true
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${CACHE_VOLUME_SIZE}
- kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: ${APPLICATION_NAME}-weblate-data
labels:
app: ${APPLICATION_NAME}
allowVolumeExpansion: true
spec:
accessModes:
- ${WEBLATE_VOLUME_TYPE}
resources:
requests:
storage: ${WEBLATE_VOLUME_SIZE}