-
Notifications
You must be signed in to change notification settings - Fork 0
/
django-template.yml
303 lines (303 loc) · 7.72 KB
/
django-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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
kind: Template
apiVersion: v1
message: |-
The following service(s) have been created in your project: Django, PostgreSQL.
metadata:
name: django
annotations:
description: Django + Postgres, Python 3
repo: https://github.com/badri/simpledjango.git
icon: django
iconClass: icon-python
openshift.io/display-name: Django
openshift.io/long-description: This template defines resources needed to develop an Alpine based Django 2.x setup running on Python 3.6 and Nginx. It also includes resources required to create a PostgreSQL instance.
tags: quickstart,python,django,shapeblock
template.openshift.io/bindable: "false"
labels:
template: django
from: shapeblock
objects:
- apiVersion: v1
kind: DeploymentConfig
metadata:
name: ${NAME}
labels:
type: app
stack: django
spec:
replicas: 1
selector:
app: ${NAME}
template:
metadata:
labels:
app: ${NAME}
spec:
volumes:
# Create the shared files volume to be used in both pods
- name: nginx
emptyDir: {}
containers:
- name: django
image: ' '
env:
- name: DJANGO_SECRET_KEY
valueFrom:
secretKeyRef:
key: django-secret-key
name: ${NAME}-db-secret
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
key: database-user
name: ${NAME}-db-secret
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
key: database-password
name: ${NAME}-db-secret
- name: POSTGRES_HOST
value: ${NAME}-db
- name: POSTGRES_PORT
value: "5432"
- name: POSTGRES_DB
value: ${POSTGRES_DB}
volumeMounts:
- name: nginx
mountPath: /nginx
- name: nginx
image: ' '
ports:
- name: http
containerPort: 8080
volumeMounts:
- name: nginx
mountPath: /app
triggers:
- type: ConfigChange
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- django
from:
kind: "ImageStreamTag"
name: ${NAME}:latest
- type: ImageChange
imageChangeParams:
automatic: true
containerNames:
- nginx
from:
kind: "ImageStreamTag"
name: nginx-django:1.17
namespace: openshift
- apiVersion: v1
kind: Service
metadata:
name: ${NAME}
spec:
selector:
app: ${NAME}
ports:
- name: http
port: 8080
protocol: TCP
- apiVersion: v1
kind: Secret
metadata:
name: ${NAME}-db-secret
stringData:
database-user: ${POSTGRES_USER}
database-password: ${POSTGRES_PASSWORD}
django-secret-key: ${DJANGO_SECRET_KEY}
- apiVersion: v1
kind: DeploymentConfig
metadata:
name: ${NAME}-db
labels:
type: service
spec:
replicas: 1
selector:
name: ${NAME}-db
strategy:
type: Recreate
template:
metadata:
labels:
name: ${NAME}-db
spec:
containers:
- env:
- name: POSTGRESQL_USER
valueFrom:
secretKeyRef:
key: database-user
name: ${NAME}-db-secret
- name: POSTGRESQL_PASSWORD
valueFrom:
secretKeyRef:
key: database-password
name: ${NAME}-db-secret
- name: POSTGRESQL_DATABASE
value: ${POSTGRES_DB}
image: ' '
livenessProbe:
exec:
command:
- /usr/libexec/check-container
- --live
initialDelaySeconds: 120
timeoutSeconds: 10
name: postgresql
ports:
- containerPort: 5432
readinessProbe:
exec:
command:
- /usr/libexec/check-container
initialDelaySeconds: 5
timeoutSeconds: 1
resources:
limits:
memory: ${DB_MEMORY_LIMIT}
volumeMounts:
- mountPath: /var/lib/pgsql/data
name: ${NAME}-db-data
volumes:
- name: ${NAME}-db-data
persistentVolumeClaim:
claimName: ${NAME}-db
triggers:
- imageChangeParams:
automatic: true
containerNames:
- postgresql
from:
kind: ImageStreamTag
name: postgresql:10
namespace: openshift
type: ImageChange
- type: ConfigChange
- apiVersion: v1
kind: Service
metadata:
name: ${NAME}-db
spec:
ports:
- name: postgresql
port: 5432
targetPort: 5432
selector:
name: ${NAME}-db
- apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: ${NAME}-db
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
storage: ${DB_VOLUME_CAPACITY}
- apiVersion: v1
kind: ImageStream
metadata:
name: ${NAME}
- apiVersion: v1
kind: BuildConfig
metadata:
name: ${NAME}
spec:
source:
git:
ref: ${SOURCE_REPOSITORY_REF}
uri: ${SOURCE_REPOSITORY_URL}
type: Git
output:
to:
kind: ImageStreamTag
name: ${NAME}:latest
strategy:
sourceStrategy:
from:
kind: ImageStreamTag
name: django:3.6
namespace: openshift
type: Source
triggers:
- type: ImageChange
- type: ConfigChange
- github:
secret: ${GITHUB_WEBHOOK_SECRET}
type: GitHub
- apiVersion: v1
kind: Route
metadata:
name: ${NAME}
spec:
host: ${APPLICATION_DOMAIN}
tls:
termination: edge
to:
kind: Service
name: ${NAME}
parameters:
- description: The name assigned to all of the frontend objects defined in this template.
displayName: Name
name: NAME
required: true
from: 'django-[a-f0-9]{6}'
generate: expression
- description: Maximum amount of memory the App container can use.
displayName: Memory Limit
name: APP_MEMORY_LIMIT
required: true
value: 512Mi
- description: Maximum amount of memory the Postgres container can use.
displayName: Memory Limit (Postgres)
name: DB_MEMORY_LIMIT
required: true
value: 1Gi
- description: Volume space available for DB data, e.g. 512Mi, 2Gi
displayName: Volume Capacity
name: DB_VOLUME_CAPACITY
required: true
value: 1Gi
- description: The URL of the repository with your application source code.
displayName: Git Repository URL
name: SOURCE_REPOSITORY_URL
required: true
value: https://github.com/badri/simpledjango.git
- description: Set this to a branch name, tag or other ref of your repository if you
are not using the default branch.
displayName: Git Reference
name: SOURCE_REPOSITORY_REF
- description: The exposed hostname that will route to the LEMP service, if left
blank a value will be defaulted.
displayName: Application Hostname
name: APPLICATION_DOMAIN
- description: Github trigger secret. A difficult to guess string encoded as part
of the webhook URL. Not encrypted.
displayName: GitHub Webhook Secret
from: '[a-zA-Z0-9]{40}'
generate: expression
name: GITHUB_WEBHOOK_SECRET
- displayName: Database Name
name: POSTGRES_DB
required: true
value: django
- name: DJANGO_SECRET_KEY
displayName: Django secret key
description: Unique secret key for Django app
generate: expression
from: '[a-zA-Z0-9_]{40}'
- displayName: Database User
name: POSTGRES_USER
required: true
value: django
- displayName: Database Password
from: '[a-zA-Z0-9]{16}'
generate: expression
name: POSTGRES_PASSWORD