-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathdefectdojo-postgres-openshift.yml
298 lines (255 loc) · 8.08 KB
/
defectdojo-postgres-openshift.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
apiVersion: v1
kind: Template
metadata:
name: "DefectDojo"
annotation:
openshift.io/display-name: "DefectDojo"
description: "DefectDojo is a security tool that automates application security vulnerability management."
openshift.io/documentation-url: "https://defectdojo.readthedocs.io/en/latest/"
iconClass: "icon-django"
labels:
template: "defect-dojo-template"
message: "The DefectDojo service hostname: ${DOJO_FQDN}"
parameters:
- name: NAMESPACE
displayName: "Project namespace"
description: "OC namespace to deploy into"
required: true
value: ""
- name: DOJO_FQDN
displayName: "DefectDojo FQDN"
description: "Externally accessible DefectDojo's hostname"
required: true
value: ""
- name: POSTGRES_HOST
displayName: "Hostname of external postgres DB"
description: "Hostname of external postgres DB"
required: true
value: ""
- name: POSTGRES_PORT
displayName: "Port of external postgres db"
description: "External Postgres port"
required: true
value: "5432"
- name: POSTGRES_DB
displayName: "Name for the default database"
description: "Name for the default database"
required: true
value: "dojo"
- name: POSTGRES_USER
displayName: "Postgres superuser name"
description: "Postgres user with superuser power"
required: true
value: ""
- name: POSTGRES_PASSWORD
displayName: "Postgres superuser password"
description: "Postgres superuser password"
required: true
value: ""
- name: DEFECTDOJO_ADMIN_PASSWORD
displayName: "Defect Dojo Superuser password"
description: "Defect Dojo Superuser password"
required: true
value: ""
- name: DEFECTDOJO_ADMIN_USER
displayName: D"efect Dojo Superuser"
description: "Defect Dojo Superuser"
required: true
value: ""
- name: FLUSH_DB
displayName: "Controls database flushing during deployment"
description: "Set 'No' is you want to use dojo database as it is"
required: true
value: "No"
- name: C_FORCE_ROOT
displayName: "Running a celery worker with superuser privileges"
description: "Running a worker with superuser privileges when the worker accepts messages serialized with pickle is a very bad idea! Please think about this before you do!"
required: true
value: "True"
- name: EXTERNAL_SECRETS
displayName: "Controls django secrets generation source"
description: "Controls django secrets generation source. If set to yes 'SECRET' and 'AES_PASSPHRASE' env variables will be expected."
required: true
value: "Yes"
- name: SECRET
description: Set this to a long random string.
displayName: Django Secret Key
from: "[\\w]{128}"
generate: expression
- name: AES_PASSPHRASE
description: Set this to a long random string.
displayName: Django Secret Key
from: "[\\w]{128}"
generate: expression
objects:
- kind: Secret
apiVersion: v1
metadata:
name: defect-dojo-secrets
stringData:
DEFECTDOJO_ADMIN_PASSWORD: ${DEFECTDOJO_ADMIN_PASSWORD}
POSTGRES_PASSWORD: ${POSTGRES_PASSWORD}
- kind: Service
apiVersion: v1
metadata:
name: defect-dojo
namespace: ${NAMESPACE}
labels:
app: defect-dojo
annotations:
description: Exposes and load balances the application pods
spec:
selector:
app: defect-dojo
ports:
- name: defect-dojo
port: 8000
protocol: TCP
targetPort: 8000
- kind: Route
apiVersion: v1
metadata:
name: defect-dojo
namespace: ${NAMESPACE}
annotations:
description: Route for DefectDojo service
labels:
app: defect-dojo
spec:
host: ${DOJO_FQDN}
tls:
insecureEdgeTerminationPolicy: Redirect
termination: edge
port:
targetPort: defect-dojo
to:
kind: Service
name: defect-dojo
wildcardPolicy: None
- kind: ConfigMap
apiVersion: v1
metadata:
name: dojo-env-settings
data:
.env.prod: |
# Django Debug, don't enable on production!
DD_DEBUG=off
# Enables Django Admin
DD_DJANGO_ADMIN_ENABLED=on
# A secret key for a particular Django installation.
DD_SECRET_KEY=${SECRET}
# Key for encrypting credentials in the manager
DD_CREDENTIAL_AES_256_KEY=${AES_PASSPHRASE}
# Database URL, options: postgres://, mysql://, sqlite://, to use unsafe characters encode with urllib.parse.encode
DD_DATABASE_URL=postgres://${POSTGRES_USER}:${POSTGRES_PASSWORD}@${POSTGRES_HOST}:${POSTGRES_PORT}/${POSTGRES_DB}
# Hosts/domain names that are valid for this site;
DD_ALLOWED_HOSTS=${DOJO_FQDN}
# WhiteNoise allows your web app to serve its own static files,
# making it a self-contained unit that can be deployed anywhere without relying on nginx,
# if using nginx then disable Whitenoise
DD_WHITENOISE=on
# -------------------------------------------------------
# Additional Settings / Override defaults in settings.py
# -------------------------------------------------------
# Timezone
# DD_TIME_ZONE=America/New_York
# Track migrations through source control rather than making migrations locally
# DD_TRACK_MIGRATIONS=on
# Whether to use HTTPOnly flag on the session cookie.
DD_SESSION_COOKIE_HTTPONLY=on
# Whether to use HttpOnly flag on the CSRF cookie.
DD_CSRF_COOKIE_HTTPONLY=on
# If True, the SecurityMiddleware redirects all non-HTTPS requests to HTTPS
# DD_SECURE_SSL_REDIRECT=off
# Whether to use a secure cookie for the CSRF cookie.
DD_CSRF_COOKIE_SECURE=off
# If on, the SecurityMiddleware sets the X-XSS-Protection: 1;
DD_SECURE_BROWSER_XSS_FILTER=on
# Change the default language set
# DD_LANG=en-us
# Path to PDF library
# DD_WKHTMLTOPDF=/usr/local/bin/wkhtmltopdf
# Security team name, used for outgoing emails
DD_TEAM_NAME=Security
# Admins for log emails
DD_ADMINS=admin:admin@localhost
# Port scan contact email
# DD_PORT_SCAN_CONTACT_EMAIL=email@localhost
# Port scan from email
# DD_PORT_SCAN_RESULT_EMAIL_FROM=email@localhost
# Port scan email list
# DD_PORT_SCAN_EXTERNAL_UNIT_EMAIL_LIST=['email@localhost']
# Port scan source
# DD_PORT_SCAN_SOURCE_IP=127.0.0.1
- kind: DeploymentConfig
apiVersion: v1
metadata:
labels:
app: defect-dojo
name: defect-dojo
namespace: ${NAMESPACE}
spec:
replicas: 1
selector:
deploymentconfig: defect-dojo
strategy:
type: Recreate
activeDeadlineSeconds: 21600
recreateParams:
timeoutSeconds: 6000
resources: {}
template:
metadata:
labels:
app: defect-dojo
deploymentconfig: defect-dojo
spec:
containers:
- image: dplmnt/defectdojo-openshift:latest
imagePullPolicy: Always
name: defect-dojo
ports:
- containerPort: 8000
protocol: TCP
env:
- name: FLUSH_DB
value: ${FLUSH_DB}
- name: DEFECTDOJO_ADMIN_PASSWORD
valueFrom:
secretKeyRef:
name: defect-dojo-secrets
key: DEFECTDOJO_ADMIN_PASSWORD
- name: DEFECTDOJO_ADMIN_USER
value: ${DEFECTDOJO_ADMIN_USER}
- name: DBTYPE
value: "2"
- name: EXTERNAL_SECRETS
value: ${EXTERNAL_SECRETS}
- name: SQLHOST
value: ${POSTGRES_HOST}
- name: SQLPORT
value: ${POSTGRES_PORT}
- name: DBNAME
value: ${POSTGRES_DB}
- name: SQLUSER
value: ${POSTGRES_USER}
- name: SQLPWD
valueFrom:
secretKeyRef:
name: defect-dojo-secrets
key: POSTGRES_PASSWORD
volumeMounts:
- mountPath: /opt/django-DefectDojo/dojo/settings/.env.prod
name: dojo-env-settings
subPath: .env.prod
dnsPolicy: ClusterFirst
restartPolicy: Always
terminationGracePeriodSeconds: 30
volumes:
- configMap:
defaultMode: 420
name: dojo-env-settings
name: dojo-env-settings
test: false
triggers:
- type: ConfigChange