diff --git a/docs/content/en/getting_started/configuration.md b/docs/content/en/getting_started/configuration.md index 402689a2164..aa97ec84b80 100644 --- a/docs/content/en/getting_started/configuration.md +++ b/docs/content/en/getting_started/configuration.md @@ -23,7 +23,7 @@ When you deploy DefectDojo in a **Kubernetes** cluster, you can set environment An example can be found in [`template_env`](https://github.com/DefectDojo/django-DefectDojo/blob/master/dojo/settings/template-env). -### local_settings.py (not with Kubernetes) +### local_settings.py `local_settings.py` can contain more complex customizations such as adding MIDDLEWARE or INSTALLED_APP entries. 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 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. +`local_settings.py` can be used in Kubernetes as well. Variable `localsettingspy` will be stored as ConfigMap and mounted to responsible location of containers. + ## Configuration in the UI Users with the superuser status can configure more options via the UI under `Configuration` / `System Settings`. diff --git a/helm/defectdojo/templates/celery-beat-deployment.yaml b/helm/defectdojo/templates/celery-beat-deployment.yaml index 973c2c857a2..9108b2b7aaf 100644 --- a/helm/defectdojo/templates/celery-beat-deployment.yaml +++ b/helm/defectdojo/templates/celery-beat-deployment.yaml @@ -49,6 +49,11 @@ spec: volumes: - name: run emptyDir: {} + {{- if .Values.localsettingspy }} + - name: localsettingspy + configMap: + name: {{ $fullName }}-localsettingspy + {{- end }} {{- if .Values.django.uwsgi.certificates.enabled }} - name: cert-mount configMap: @@ -107,6 +112,12 @@ spec: volumeMounts: - name: run mountPath: /run/defectdojo + {{- if .Values.localsettingspy }} + - name: localsettingspy + readOnly: true + mountPath: /app/dojo/settings/local_settings.py + subPath: file + {{- end }} {{- if .Values.django.uwsgi.certificates.enabled }} - name: cert-mount mountPath: {{ .Values.django.uwsgi.certificates.certMountPath }} diff --git a/helm/defectdojo/templates/celery-worker-deployment.yaml b/helm/defectdojo/templates/celery-worker-deployment.yaml index 4ac4ddce894..2f0dbf7e747 100644 --- a/helm/defectdojo/templates/celery-worker-deployment.yaml +++ b/helm/defectdojo/templates/celery-worker-deployment.yaml @@ -47,6 +47,11 @@ spec: - name: {{ .Values.imagePullSecrets }} {{- end }} volumes: + {{- if .Values.localsettingspy }} + - name: localsettingspy + configMap: + name: {{ $fullName }}-localsettingspy + {{- end }} {{- if .Values.django.uwsgi.certificates.enabled }} - name: cert-mount configMap: @@ -102,6 +107,12 @@ spec: {{- end }} command: ['/entrypoint-celery-worker.sh'] volumeMounts: + {{- if .Values.localsettingspy }} + - name: localsettingspy + readOnly: true + mountPath: /app/dojo/settings/local_settings.py + subPath: file + {{- end }} {{- if .Values.django.uwsgi.certificates.enabled }} - name: cert-mount mountPath: {{ .Values.django.uwsgi.certificates.certMountPath }} diff --git a/helm/defectdojo/templates/configmap-local-settings-py.yaml b/helm/defectdojo/templates/configmap-local-settings-py.yaml new file mode 100644 index 00000000000..dc75942fbc0 --- /dev/null +++ b/helm/defectdojo/templates/configmap-local-settings-py.yaml @@ -0,0 +1,15 @@ +{{- if .Values.localsettingspy }} +{{- $fullName := include "defectdojo.fullname" . -}} +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ $fullName }}-localsettingspy + labels: + app.kubernetes.io/name: {{ include "defectdojo.name" . }} + app.kubernetes.io/instance: {{ .Release.Name }} + app.kubernetes.io/managed-by: {{ .Release.Service }} + helm.sh/chart: {{ include "defectdojo.chart" . }} +data: + file: + {{ toYaml .Values.localsettingspy | indent 4 }} +{{- end }} diff --git a/helm/defectdojo/templates/django-deployment.yaml b/helm/defectdojo/templates/django-deployment.yaml index d8610810fb4..a543898b171 100644 --- a/helm/defectdojo/templates/django-deployment.yaml +++ b/helm/defectdojo/templates/django-deployment.yaml @@ -56,6 +56,11 @@ spec: volumes: - name: run emptyDir: {} + {{- if .Values.localsettingspy }} + - name: localsettingspy + configMap: + name: {{ $fullName }}-localsettingspy + {{- end }} {{- if .Values.django.uwsgi.certificates.enabled }} - name: cert-mount configMap: @@ -138,6 +143,12 @@ spec: volumeMounts: - name: run mountPath: /run/defectdojo + {{- if .Values.localsettingspy }} + - name: localsettingspy + readOnly: true + mountPath: /app/dojo/settings/local_settings.py + subPath: file + {{- end }} {{- if .Values.django.uwsgi.certificates.enabled }} - name: cert-mount mountPath: {{ .Values.django.uwsgi.certificates.certMountPath }} diff --git a/helm/defectdojo/templates/initializer-job.yaml b/helm/defectdojo/templates/initializer-job.yaml index 7018c515ce0..77dc5820c01 100644 --- a/helm/defectdojo/templates/initializer-job.yaml +++ b/helm/defectdojo/templates/initializer-job.yaml @@ -38,6 +38,11 @@ spec: - name: {{ .Values.imagePullSecrets }} {{- end }} volumes: + {{- if .Values.localsettingspy }} + - name: localsettingspy + configMap: + name: {{ $fullName }}-localsettingspy + {{- end }} {{- range .Values.initializer.extraVolumes }} - name: userconfig-{{ .name }} {{ .type }}: @@ -101,6 +106,12 @@ spec: {{- toYaml .Values.securityContext.djangoSecurityContext | nindent 10 }} {{- end }} volumeMounts: + {{- if .Values.localsettingspy }} + - name: localsettingspy + readOnly: true + mountPath: /app/dojo/settings/local_settings.py + subPath: file + {{- end }} {{- range .Values.initializer.extraVolumes }} - name: userconfig-{{ .name }} readOnly: true diff --git a/helm/defectdojo/values.yaml b/helm/defectdojo/values.yaml index 555d66c4757..12c84b6362c 100644 --- a/helm/defectdojo/values.yaml +++ b/helm/defectdojo/values.yaml @@ -521,3 +521,15 @@ extraConfigs: {} # configMapKeyRef: # name: my-other-postgres-configmap # key: cluster_endpoint + +# To add code snippet which would extend setting functionality, you might add it here +# It will be stored as ConfigMap and mounted `dojo/settings/local_settings.py`. +# For more see: https://documentation.defectdojo.com/getting_started/configuration/ +# For example: +# localsettingspy: | +# INSTALLED_APPS += ( +# 'debug_toolbar', +# ) +# MIDDLEWARE = [ +# 'debug_toolbar.middleware.DebugToolbarMiddleware', +# ] + MIDDLEWARE