Skip to content

Commit 005ad5a

Browse files
helm: helm chart enhancements (#10612)
* replace site url variable name to match values.yaml style * rework app settings block in values.yaml to match file style * rework uwsgi debug variable setting * fix configmap boolean value to string * remove unneded variable * update release documentation * fix variable name * move documentation to the next realease notes * change description in the changelog * remove empty line at the end of file
1 parent d851dad commit 005ad5a

File tree

6 files changed

+79
-39
lines changed

6 files changed

+79
-39
lines changed

docs/content/en/getting_started/upgrading/2.38.md

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,27 @@
22
title: 'Upgrading to DefectDojo Version 2.38.x'
33
toc_hide: true
44
weight: -20240805
5-
description: No special instructions.
5+
description: Breaking Change for HELM deployments
66
---
7-
There are no special instructions for upgrading to 2.38.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.38.0) for the contents of the release.
7+
8+
**Breaking Change**
9+
10+
Previous HELM `values.yaml` file was not following the official HELM best practicies on key naming - [https://helm.sh/docs/chart_best_practices/values/#naming-conventions](https://helm.sh/docs/chart_best_practices/values/#naming-conventions)
11+
12+
The following `snake_case` keys are replaced with `camelCase` keys in the `values.yaml`:
13+
14+
- `site_url` is replaced with `siteUrl`
15+
- `celery.worker.app_settings` block is replaced with `celery.worker.appSettings`. In this block:
16+
17+
- `pool_type` is replaced with `poolType`
18+
- `autoscale_min` is replaced with `autoscaleMin`
19+
- `autoscale_max` is replaced with `autoscaleMax`
20+
- `prefetch_multiplier` is replaced with `prefetchMultiplier`
21+
22+
- `django.uwsgi.app_settings` block is changed to `django.uwsgi.appSettings`. In this block:
23+
24+
- `max_fd` is changed to `maxFd`
25+
26+
- `django.uwsgi.enable_debug` is changed to `django.uwsgi.enableDebug`
27+
28+
There are no other special instructions for upgrading to 2.38.x. Check the [Release Notes](https://github.com/DefectDojo/django-DefectDojo/releases/tag/2.38.0) for the contents of the release.

helm/defectdojo/templates/_helpers.tpl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ Create chart name and version as used by the chart label.
151151
name: {{ .fullName }}-extrasecrets
152152
optional: true
153153
env:
154-
{{- if .Values.django.uwsgi.enable_debug }}
154+
{{- if .Values.django.uwsgi.enableDebug }}
155155
- name: DD_DEBUG
156156
value: 'True'
157157
{{- end }}

helm/defectdojo/templates/configmap.yaml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -14,19 +14,19 @@ data:
1414
DD_ADMIN_FIRST_NAME: {{ .Values.admin.FirstName | default "Admin" }}
1515
DD_ADMIN_LAST_NAME: {{ .Values.admin.LastName | default "User" }}
1616
DD_ALLOWED_HOSTS: {{ include "django.allowed_hosts" . }}
17-
DD_SITE_URL: {{ .Values.site_url | default "http://localhost:8080" }}
17+
DD_SITE_URL: {{ .Values.siteUrl | default "http://localhost:8080" }}
1818
DD_CELERY_BROKER_SCHEME: {{ if eq .Values.celery.broker "redis" }}{{ template "redis.scheme" . }}{{ end }}
1919
DD_CELERY_BROKER_USER: ''
2020
DD_CELERY_BROKER_HOST: {{ if eq .Values.celery.broker "redis" }}{{ template "redis.hostname" . }}{{ end }}
2121
DD_CELERY_BROKER_PORT: '{{ if eq .Values.celery.broker "redis" }}{{ .Values.redis.master.service.ports.redis | default "6379" }}{{ end }}'
2222
DD_CELERY_BROKER_PARAMS: '{{ if eq .Values.celery.broker "redis" }}{{- if .Values.redis.transportEncryption.enabled -}}{{ .Values.redis.transportEncryption.params | default "ssl_cert_reqs=optional" }}{{ end }}{{ end }}'
2323
DD_CELERY_BROKER_PATH: '{{ .Values.celery.path | default "//" }}'
2424
DD_CELERY_LOG_LEVEL: {{ .Values.celery.logLevel }}
25-
DD_CELERY_WORKER_POOL_TYPE: {{ .Values.celery.worker.app_settings.pool_type | default "solo" }}
26-
DD_CELERY_WORKER_AUTOSCALE_MIN: '{{ if eq .Values.celery.worker.app_settings.pool_type "prefork" }}{{ .Values.celery.worker.app_settings.autoscale_min | default "2" }}{{ end }}'
27-
DD_CELERY_WORKER_AUTOSCALE_MAX: '{{ if eq .Values.celery.worker.app_settings.pool_type "prefork" }}{{ .Values.celery.worker.app_settings.autoscale_max | default "8" }}{{ end }}'
28-
DD_CELERY_WORKER_CONCURRENCY: '{{ if eq .Values.celery.worker.app_settings.pool_type "prefork" }}{{ .Values.celery.worker.app_settings.concurrency | default "8" }}{{ end }}'
29-
DD_CELERY_WORKER_PREFETCH_MULTIPLIER: '{{ if eq .Values.celery.worker.app_settings.pool_type "prefork" }}{{ .Values.celery.worker.app_settings.prefetch_multiplier | default "128" }}{{ end }}'
25+
DD_CELERY_WORKER_POOL_TYPE: {{ .Values.celery.worker.appSettings.poolType | default "solo" }}
26+
DD_CELERY_WORKER_AUTOSCALE_MIN: '{{ if eq .Values.celery.worker.appSettings.poolType "prefork" }}{{ .Values.celery.worker.appSettings.autoscaleMin | default "2" }}{{ end }}'
27+
DD_CELERY_WORKER_AUTOSCALE_MAX: '{{ if eq .Values.celery.worker.appSettings.poolType "prefork" }}{{ .Values.celery.worker.appSettings.autoscaleMax | default "8" }}{{ end }}'
28+
DD_CELERY_WORKER_CONCURRENCY: '{{ if eq .Values.celery.worker.appSettings.poolType "prefork" }}{{ .Values.celery.worker.appSettings.concurrency | default "8" }}{{ end }}'
29+
DD_CELERY_WORKER_PREFETCH_MULTIPLIER: '{{ if eq .Values.celery.worker.appSettings.poolType "prefork" }}{{ .Values.celery.worker.appSettings.prefetchMultiplier | default "128" }}{{ end }}'
3030
DD_DATABASE_ENGINE: django.db.backends.{{ if eq .Values.database "postgresql" }}postgresql{{ end }}{{ if eq .Values.database "postgresqlha" }}postgresql{{ end }}
3131
DD_DATABASE_HOST: {{ if eq .Values.database "postgresql" }}{{ template "postgresql.hostname" . }}{{ end }}{{ if eq .Values.database "postgresqlha" }}{{ template "postgresqlha.hostname" . }}{{ end }}
3232
DD_DATABASE_PORT: '{{ if eq .Values.database "postgresql" }}{{ .Values.postgresql.primary.service.ports.postgresql }}{{ end }}{{ if eq .Values.database "postgresqlha" }}{{ .Values.postgresqlha.service.ports.postgresql }}{{ end }}'
@@ -36,9 +36,9 @@ data:
3636
DD_UWSGI_ENDPOINT: /run/defectdojo/uwsgi.sock
3737
DD_UWSGI_HOST: localhost
3838
DD_UWSGI_PASS: unix:///run/defectdojo/uwsgi.sock
39-
DD_UWSGI_NUM_OF_PROCESSES: '{{ .Values.django.uwsgi.app_settings.processes | default 2 }}'
40-
DD_UWSGI_NUM_OF_THREADS: '{{ .Values.django.uwsgi.app_settings.threads | default 2 }}'
41-
DD_UWSGI_MAX_FD: '{{ .Values.django.uwsgi.app_settings.max_fd }}'
39+
DD_UWSGI_NUM_OF_PROCESSES: '{{ .Values.django.uwsgi.appSettings.processes | default 2 }}'
40+
DD_UWSGI_NUM_OF_THREADS: '{{ .Values.django.uwsgi.appSettings.threads | default 2 }}'
41+
DD_UWSGI_MAX_FD: '{{ .Values.django.uwsgi.appSettings.maxFd }}'
4242
DD_DJANGO_METRICS_ENABLED: '{{ .Values.monitoring.enabled }}'
4343
NGINX_METRICS_ENABLED: '{{ .Values.monitoring.enabled }}'
4444
METRICS_HTTP_AUTH_USER: {{ .Values.monitoring.user | default "monitoring" }}

helm/defectdojo/templates/django-deployment.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ spec:
155155
- name: http-uwsgi
156156
protocol: TCP
157157
containerPort: 8081
158-
{{- if .Values.django.uwsgi.enable_debug }}
158+
{{- if .Values.django.uwsgi.enableDebug }}
159159
- name: debug
160160
protocol: TCP
161161
containerPort: 3000
@@ -174,7 +174,7 @@ spec:
174174
name: {{ .Values.redis.auth.existingSecret | default "defectdojo-redis-specific" }}
175175
key: {{ .Values.redis.auth.existingSecretPasswordKey | default "redis-password" }}
176176
{{- end }}
177-
{{- if .Values.django.uwsgi.enable_debug }}
177+
{{- if .Values.django.uwsgi.enableDebug }}
178178
- name: DD_DEBUG
179179
value: 'True'
180180
{{- end }}

helm/defectdojo/values.yaml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ database: postgresql
4242
host: defectdojo.default.minikube.local
4343

4444
# The full URL to your defectdojo instance, depends on the domain where DD is deployed, it also affects links in Jira
45-
# site_url: 'https://<yourdomain>'
45+
# siteUrl: 'https://<yourdomain>'
4646

4747
# optional list of alternative hostnames to use that gets appended to
4848
# DD_ALLOWED_HOSTS. This is necessary when your local hostname does not match
@@ -139,15 +139,15 @@ celery:
139139
cpu: 2000m
140140
memory: 512Mi
141141
tolerations: []
142-
app_settings:
143-
pool_type: solo
142+
appSettings:
143+
poolType: solo
144144
# Performance improved celery worker config when needing to deal with a lot of findings (e.g deduplication ops)
145145
# Comment out the "solo" line, and uncomment the following lines.
146-
# pool_type: prefork
147-
# autoscale_min: 2
148-
# autoscale_max: 8
146+
# poolType: prefork
147+
# autoscaleMin: 2
148+
# autoscaleMax: 8
149149
# concurrency: 8
150-
# prefetch_multiplier: 128
150+
# prefetchMultiplier: 128
151151

152152
# A list of extra volumes to mount. This
153153
# is useful for bringing in extra data that can be referenced by other configurations
@@ -228,11 +228,11 @@ django:
228228
limits:
229229
cpu: 2000m
230230
memory: 512Mi
231-
app_settings:
231+
appSettings:
232232
processes: 2
233233
threads: 2
234-
# max_fd: 102400 # Uncomment to set the maximum number of file descriptors. If not set will be detected by uwsgi
235-
enable_debug: false # this also requires DD_DEBUG to be set to True
234+
# maxFd: 102400 # Uncomment to set the maximum number of file descriptors. If not set will be detected by uwsgi
235+
enableDebug: false # this also requires DD_DEBUG to be set to True
236236
certificates:
237237
# includes additional CA certificate as volume, it refrences REQUESTS_CA_BUNDLE env varible
238238
# to create configMap `kubectl create cm defectdojo-ca-certs --from-file=ca.crt`

readme-docs/KUBERNETES.md

Lines changed: 34 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,11 @@ and [Helm](https://helm.sh/) can be installed locally by following
1010
this [guide](https://helm.sh/docs/using_helm/#installing-helm).
1111

1212
## Supported Kubernetes Versions
13+
1314
The tests cover the deployment on the lastest [kubernetes version](https://kubernetes.io/releases/) and the oldest supported [version from AWS](https://docs.aws.amazon.com/eks/latest/userguide/kubernetes-versions.html#available-versions). The assumption is that version in between do not have significant differences. Current tested versions can looks up in the [github k8s workflow](https://github.com/DefectDojo/django-DefectDojo/blob/master/.github/workflows/k8s-tests.yml).
1415

1516
## Helm chart
17+
1618
Starting with version 1.14.0, a helm chart will be pushed onto the `helm-charts` branch during the release process. Don't look for a chart museum, we're leveraging the "raw" capabilities of GitHub at this time.
1719

1820
To use it, you can add our repo.
@@ -49,31 +51,40 @@ minikube addons enable ingress
4951
```
5052

5153
Helm >= v3
54+
5255
```zsh
5356
helm repo add bitnami https://charts.bitnami.com/bitnami
5457
helm repo update
5558
```
59+
5660
Then pull the dependent charts:
61+
5762
```zsh
5863
helm dependency update ./helm/defectdojo
5964
```
6065

6166
Now, install the helm chart into minikube.
6267

6368
If you have setup an ingress controller:
69+
6470
```zsh
6571
DJANGO_INGRESS_ENABLED=true
6672
```
73+
6774
else:
75+
6876
```zsh
6977
DJANGO_INGRESS_ENABLED=false
7078
```
7179

7280
If you have configured TLS:
81+
7382
```zsh
7483
DJANGO_INGRESS_ACTIVATE_TLS=true
7584
```
85+
7686
else:
87+
7788
```zsh
7889
DJANGO_INGRESS_ACTIVATE_TLS=false
7990
```
@@ -94,7 +105,7 @@ helm install \
94105
```
95106

96107
It usually takes up to a minute for the services to startup and the
97-
status of the containers can be viewed by starting up ```minikube dashboard```.
108+
status of the containers can be viewed by starting up `minikube dashboard`.
98109
Note: If the containers are not cached locally the services will start once the
99110
containers have been pulled locally.
100111

@@ -134,15 +145,18 @@ If testing containers locally, then set the imagePullPolicy to Never,
134145
which ensures containers are not pulled from Docker hub.
135146

136147
Use the same commands as before but add:
148+
137149
```zsh
138150
--set imagePullPolicy=Never
139151
```
140152

141153
### Installing from a private registry
154+
142155
If you have stored your images in a private registry, you can install defectdojo chart with (helm 3).
143156

144157
- First create a secret named "defectdojoregistrykey" based on the credentials that can pull from the registry: see https://kubernetes.io/docs/tasks/configure-pod-container/pull-image-private-registry/
145158
- Then install the chart with the same commands as before but adding:
159+
146160
```zsh
147161
--set repositoryPrefix=<myregistry.com/path> \
148162
--set imagePullSecrets=defectdojoregistrykey
@@ -168,21 +182,23 @@ You can set breakpoints in code that is handled by uWSGI. The feature is meant t
168182

169183
The port is currently hard-coded to 3000.
170184

171-
* In `values.yaml`, ensure the value for `enable_ptvsd` is set to `true` (the default is `false`). Make sure the change is taken into account in your deployment.
172-
* Have `DD_DEBUG` set to `True`.
173-
* Port forward port 3000 to the pod, such as `kubectl port-forward defectdojo-django-7886f49466-7cwm7 3000`.
185+
- In `values.yaml`, ensure the value for `enable_ptvsd` is set to `true` (the default is `false`). Make sure the change is taken into account in your deployment.
186+
- Have `DD_DEBUG` set to `True`.
187+
- Port forward port 3000 to the pod, such as `kubectl port-forward defectdojo-django-7886f49466-7cwm7 3000`.
174188

175189
### Upgrade the chart
190+
176191
If you want to change kubernetes configuration of use an updated docker image (evolution of defectDojo code), upgrade the application:
192+
177193
```
178194
kubectl delete job defectdojo-initializer
179195
helm upgrade defectdojo ./helm/defectdojo/ \
180196
--set django.ingress.enabled=${DJANGO_INGRESS_ENABLED} \
181197
--set django.ingress.activateTLS=${DJANGO_INGRESS_ACTIVATE_TLS}
182198
```
183199

184-
185200
### Re-install the chart
201+
186202
In case of issue or in any other situation where you need to re-install the chart, you can do it and re-use the same secrets.
187203

188204
**Note: With postgresql you'll keep the same database (more information below)**
@@ -229,7 +245,6 @@ If you want to encrypt the traffic to the nginx server you can use the option `-
229245

230246
Be aware that the traffic to the database and celery broker are unencrypted at the moment.
231247

232-
233248
### Media persistent volume
234249

235250
By default, DefectDojo helm installation doesn't support persistent storage for storing images (dynamically uploaded by users). By default, it uses emptyDir, which is ephemeral by its nature and doesn't support multiple replicas of django pods, so should not be in use for production.
@@ -245,7 +260,7 @@ mediaPersistentVolume:
245260
type: pvc
246261
# there are two options to create pvc 1) when you want the chart to create pvc for you, set django.mediaPersistentVolume.persistentVolumeClaim.create to true and do not specify anything for django.mediaPersistentVolume.PersistentVolumeClaim.name 2) when you want to create pvc outside the chart, pass the pvc name via django.mediaPersistentVolume.PersistentVolumeClaim.name and ensure django.mediaPersistentVolume.PersistentVolumeClaim.create is set to false
247262
persistentVolumeClaim:
248-
create: true
263+
create: true
249264
name:
250265
size: 5Gi
251266
accessModes:
@@ -327,10 +342,12 @@ It's possible to enable Nginx prometheus exporter by setting `--set monitoring.e
327342
## Useful stuff
328343

329344
### Setting your own domain
330-
The `site_url` in values.yaml controls what domain is configured in Django, and also what the celery workers will put as links in Jira tickets for example.
345+
346+
The `siteUrl` in values.yaml controls what domain is configured in Django, and also what the celery workers will put as links in Jira tickets for example.
331347
Set this to your `https://<yourdomain>` in values.yaml
332348

333349
### Multiple Hostnames
350+
334351
Django requires a list of all hostnames that are valid for requests.
335352
You can add additional hostnames via helm or values file as an array.
336353
This helps if you have a local service submitting reports to defectDojo using
@@ -347,30 +364,29 @@ This will also work with shell inserted variables:
347364
You will still need to set a host value as well.
348365

349366
### Using an existing redis setup with redis-sentinel
367+
350368
If you want to use a redis-sentinel setup as the Celery broker, you will need to set the following.
351369

352370
1. Set redis.scheme to "sentinel" in values.yaml
353371
2. Set two additional extraEnv vars specifying the sentinel master name and port in values.yaml
354372

355373
```yaml
356374
celery:
357-
broker: "redis"
375+
broker: 'redis'
358376

359377
redis:
360-
redisServer: "PutYourRedisSentinelAddress"
361-
scheme: "sentinel"
378+
redisServer: 'PutYourRedisSentinelAddress'
379+
scheme: 'sentinel'
362380

363381
extraEnv:
364382
- name: DD_CELERY_BROKER_TRANSPORT_OPTIONS
365383
value: '{"master_name": "mymaster"}'
366384
- name: 'DD_CELERY_BROKER_PORT'
367-
value: "26379"
385+
value: '26379'
368386
```
369387
370-
371-
372-
373388
### kubectl commands
389+
374390
```zsh
375391
# View logs of a specific pod
376392
kubectl logs $(kubectl get pod --selector=defectdojo.org/component=${POD} \
@@ -388,12 +404,15 @@ kubectl exec -it $(kubectl get pod --selector=defectdojo.org/component=${POD} \
388404
```
389405

390406
### Clean up Kubernetes
407+
391408
Helm >= v3
409+
392410
```
393411
helm uninstall defectdojo
394412
```
395413

396414
To remove persistent objects not removed by uninstall (this will remove any database):
415+
397416
```
398417
kubectl delete secrets defectdojo defectdojo-redis-specific defectdojo-postgresql-specific
399418
kubectl delete serviceAccount defectdojo

0 commit comments

Comments
 (0)