Skip to content

Commit 89e17c7

Browse files
authored
feat(helm-local_settings): Add option to add local_settings.py (#10803)
1 parent 55526a0 commit 89e17c7

File tree

7 files changed

+74
-1
lines changed

7 files changed

+74
-1
lines changed

docs/content/en/open_source/installation/configuration.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ When you deploy DefectDojo in a **Kubernetes** cluster, you can set environment
2323

2424
An example can be found in [`template_env`](https://github.com/DefectDojo/django-DefectDojo/blob/master/dojo/settings/template-env).
2525

26-
### local_settings.py (not with Kubernetes)
26+
### local_settings.py
2727

2828
`local_settings.py` can contain more complex customizations such as adding MIDDLEWARE or INSTALLED_APP entries.
2929
This file is processed *after* settings.dist.py is processed, so you can modify settings delivered by DefectDojo out of the box.
@@ -34,6 +34,8 @@ An example can be found in [`dojo/settings/template-local_settings`](https://git
3434

3535
In Docker Compose release mode, files in `docker/extra_settings/` (relative to the file `docker-compose.yml`) will be copied into `dojo/settings/` in the docker container on startup.
3636

37+
`local_settings.py` can be used in Kubernetes as well. Variable `localsettingspy` will be stored as ConfigMap and mounted to responsible location of containers.
38+
3739
## Configuration in the UI
3840

3941
Users with the superuser status can configure more options via the UI under `Configuration` / `System Settings`.

helm/defectdojo/templates/celery-beat-deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,11 @@ spec:
6161
volumes:
6262
- name: run
6363
emptyDir: {}
64+
{{- if .Values.localsettingspy }}
65+
- name: localsettingspy
66+
configMap:
67+
name: {{ $fullName }}-localsettingspy
68+
{{- end }}
6469
{{- if .Values.django.uwsgi.certificates.enabled }}
6570
- name: cert-mount
6671
configMap:
@@ -119,6 +124,12 @@ spec:
119124
volumeMounts:
120125
- name: run
121126
mountPath: /run/defectdojo
127+
{{- if .Values.localsettingspy }}
128+
- name: localsettingspy
129+
readOnly: true
130+
mountPath: /app/dojo/settings/local_settings.py
131+
subPath: file
132+
{{- end }}
122133
{{- if .Values.django.uwsgi.certificates.enabled }}
123134
- name: cert-mount
124135
mountPath: {{ .Values.django.uwsgi.certificates.certMountPath }}

helm/defectdojo/templates/celery-worker-deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,11 @@ spec:
5959
- name: {{ .Values.imagePullSecrets }}
6060
{{- end }}
6161
volumes:
62+
{{- if .Values.localsettingspy }}
63+
- name: localsettingspy
64+
configMap:
65+
name: {{ $fullName }}-localsettingspy
66+
{{- end }}
6267
{{- if .Values.django.uwsgi.certificates.enabled }}
6368
- name: cert-mount
6469
configMap:
@@ -114,6 +119,12 @@ spec:
114119
{{- end }}
115120
command: ['/entrypoint-celery-worker.sh']
116121
volumeMounts:
122+
{{- if .Values.localsettingspy }}
123+
- name: localsettingspy
124+
readOnly: true
125+
mountPath: /app/dojo/settings/local_settings.py
126+
subPath: file
127+
{{- end }}
117128
{{- if .Values.django.uwsgi.certificates.enabled }}
118129
- name: cert-mount
119130
mountPath: {{ .Values.django.uwsgi.certificates.certMountPath }}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
{{- if .Values.localsettingspy }}
2+
{{- $fullName := include "defectdojo.fullname" . -}}
3+
apiVersion: v1
4+
kind: ConfigMap
5+
metadata:
6+
name: {{ $fullName }}-localsettingspy
7+
labels:
8+
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
9+
app.kubernetes.io/instance: {{ .Release.Name }}
10+
app.kubernetes.io/managed-by: {{ .Release.Service }}
11+
helm.sh/chart: {{ include "defectdojo.chart" . }}
12+
data:
13+
file:
14+
{{ toYaml .Values.localsettingspy | indent 4 }}
15+
{{- end }}

helm/defectdojo/templates/django-deployment.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,11 @@ spec:
6868
volumes:
6969
- name: run
7070
emptyDir: {}
71+
{{- if .Values.localsettingspy }}
72+
- name: localsettingspy
73+
configMap:
74+
name: {{ $fullName }}-localsettingspy
75+
{{- end }}
7176
{{- if .Values.django.uwsgi.certificates.enabled }}
7277
- name: cert-mount
7378
configMap:
@@ -150,6 +155,12 @@ spec:
150155
volumeMounts:
151156
- name: run
152157
mountPath: /run/defectdojo
158+
{{- if .Values.localsettingspy }}
159+
- name: localsettingspy
160+
readOnly: true
161+
mountPath: /app/dojo/settings/local_settings.py
162+
subPath: file
163+
{{- end }}
153164
{{- if .Values.django.uwsgi.certificates.enabled }}
154165
- name: cert-mount
155166
mountPath: {{ .Values.django.uwsgi.certificates.certMountPath }}

helm/defectdojo/templates/initializer-job.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ spec:
4444
- name: {{ .Values.imagePullSecrets }}
4545
{{- end }}
4646
volumes:
47+
{{- if .Values.localsettingspy }}
48+
- name: localsettingspy
49+
configMap:
50+
name: {{ $fullName }}-localsettingspy
51+
{{- end }}
4752
{{- range .Values.initializer.extraVolumes }}
4853
- name: userconfig-{{ .name }}
4954
{{ .type }}:
@@ -107,6 +112,12 @@ spec:
107112
{{- toYaml .Values.securityContext.djangoSecurityContext | nindent 10 }}
108113
{{- end }}
109114
volumeMounts:
115+
{{- if .Values.localsettingspy }}
116+
- name: localsettingspy
117+
readOnly: true
118+
mountPath: /app/dojo/settings/local_settings.py
119+
subPath: file
120+
{{- end }}
110121
{{- range .Values.initializer.extraVolumes }}
111122
- name: userconfig-{{ .name }}
112123
readOnly: true

helm/defectdojo/values.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -543,3 +543,15 @@ extraConfigs: {}
543543
# configMapKeyRef:
544544
# name: my-other-postgres-configmap
545545
# key: cluster_endpoint
546+
547+
# To add code snippet which would extend setting functionality, you might add it here
548+
# It will be stored as ConfigMap and mounted `dojo/settings/local_settings.py`.
549+
# For more see: https://documentation.defectdojo.com/getting_started/configuration/
550+
# For example:
551+
# localsettingspy: |
552+
# INSTALLED_APPS += (
553+
# 'debug_toolbar',
554+
# )
555+
# MIDDLEWARE = [
556+
# 'debug_toolbar.middleware.DebugToolbarMiddleware',
557+
# ] + MIDDLEWARE

0 commit comments

Comments
 (0)