Skip to content

Commit 70c766d

Browse files
committed
feat(helm): Split image locations+tags, allow digest pinning
1 parent f61e3aa commit 70c766d

File tree

13 files changed

+351
-43
lines changed

13 files changed

+351
-43
lines changed

.github/workflows/k8s-tests.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,8 @@ jobs:
6767
defectdojo \
6868
./helm/defectdojo \
6969
--set django.ingress.enabled=true \
70+
--set images.django.image.tag=latest \
71+
--set images.nginx.image.tag=latest \
7072
--set imagePullPolicy=Never \
7173
--set initializer.keepSeconds="-1" \
7274
--set redis.enabled=true \

.github/workflows/release-x-manual-helm-chart.yml

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -69,16 +69,6 @@ jobs:
6969
helm dependency list ./helm/defectdojo
7070
helm dependency update ./helm/defectdojo
7171
72-
- name: Add yq
73-
uses: mikefarah/yq@6251e95af8df3505def48c71f3119836701495d6 # v4.47.2
74-
75-
- name: Pin version docker version
76-
id: pin_image
77-
run: |-
78-
yq --version
79-
yq -i '.tag="${{ inputs.release_number }}"' helm/defectdojo/values.yaml
80-
echo "Current image tag:`yq -r '.tag' helm/defectdojo/values.yaml`"
81-
8272
- name: Package Helm chart
8373
id: package-helm-chart
8474
run: |

docs/content/en/open_source/upgrading/2.52.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ This release introduces more important changes to the Helm chart configuration:
1111

1212
### Breaking changes
1313

14+
#### Tags
15+
16+
`tag` and `repositoryPrefix` fields have been deprecated. Currently, image tags used in containers are derived by default from the `appVersion` defined in the Chart.
17+
This behavior can be overridden by setting the `tag` value in `images.django` and `images.nginx`.
18+
If fine-tuning is necessary, each container’s image value can also be customized individually (`celery.beat.image`, `celery.worker.image`, `django.nginx.image`, `django.uwsgi.image`, `initializer.image`, and `dbMigrationChecker.image`).
19+
Digest pinning is now supported as well.
20+
1421
#### Security context
1522

1623
This Helm chart extends security context capabilities to all deployed pods and containers.

helm/defectdojo/Chart.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
appVersion: "2.52.0-dev"
33
description: A Helm chart for Kubernetes to install DefectDojo
44
name: defectdojo
5-
version: 1.7.1-dev
5+
version: 1.8.0-dev
66
icon: https://defectdojo.com/hubfs/DefectDojo_favicon.png
77
maintainers:
88
- name: madchap
@@ -22,3 +22,5 @@ annotations:
2222
artifacthub.io/changes: |
2323
- kind: changed
2424
description: DRY cloudsql-proxy
25+
- kind: changed
26+
description: Each component allow to specific image + allow digest pinning

helm/defectdojo/README.md

Lines changed: 41 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ kubectl delete pvc data-defectdojo-redis-0 data-defectdojo-postgresql-0
495495
496496
# General information about chart values
497497
498-
![Version: 1.7.1-dev](https://img.shields.io/badge/Version-1.7.1--dev-informational?style=flat-square) ![AppVersion: 2.52.0-dev](https://img.shields.io/badge/AppVersion-2.52.0--dev-informational?style=flat-square)
498+
![Version: 1.8.0-dev](https://img.shields.io/badge/Version-1.8.0--dev-informational?style=flat-square) ![AppVersion: 2.52.0-dev](https://img.shields.io/badge/AppVersion-2.52.0--dev-informational?style=flat-square)
499499
500500
A Helm chart for Kubernetes to install DefectDojo
501501
@@ -533,6 +533,10 @@ A Helm chart for Kubernetes to install DefectDojo
533533
| celery.beat.extraInitContainers | list | `[]` | |
534534
| celery.beat.extraVolumeMounts | list | `[]` | |
535535
| celery.beat.extraVolumes | list | `[]` | |
536+
| celery.beat.image.digest | string | `""` | |
537+
| celery.beat.image.registry | string | `""` | |
538+
| celery.beat.image.repository | string | `""` | |
539+
| celery.beat.image.tag | string | `""` | |
536540
| celery.beat.livenessProbe | object | `{}` | |
537541
| celery.beat.nodeSelector | object | `{}` | |
538542
| celery.beat.podAnnotations | object | `{}` | |
@@ -555,6 +559,10 @@ A Helm chart for Kubernetes to install DefectDojo
555559
| celery.worker.extraInitContainers | list | `[]` | |
556560
| celery.worker.extraVolumeMounts | list | `[]` | |
557561
| celery.worker.extraVolumes | list | `[]` | |
562+
| celery.worker.image.digest | string | `""` | |
563+
| celery.worker.image.registry | string | `""` | |
564+
| celery.worker.image.repository | string | `""` | |
565+
| celery.worker.image.tag | string | `""` | |
558566
| celery.worker.livenessProbe | object | `{}` | |
559567
| celery.worker.nodeSelector | object | `{}` | |
560568
| celery.worker.podAnnotations | object | `{}` | |
@@ -586,6 +594,10 @@ A Helm chart for Kubernetes to install DefectDojo
586594
| dbMigrationChecker.enabled | bool | `true` | |
587595
| dbMigrationChecker.extraEnv | list | `[]` | |
588596
| dbMigrationChecker.extraVolumeMounts | list | `[]` | |
597+
| dbMigrationChecker.image.digest | string | `""` | |
598+
| dbMigrationChecker.image.registry | string | `""` | |
599+
| dbMigrationChecker.image.repository | string | `""` | |
600+
| dbMigrationChecker.image.tag | string | `""` | |
589601
| dbMigrationChecker.resources.limits.cpu | string | `"200m"` | |
590602
| dbMigrationChecker.resources.limits.memory | string | `"200Mi"` | |
591603
| dbMigrationChecker.resources.requests.cpu | string | `"100m"` | |
@@ -614,6 +626,10 @@ A Helm chart for Kubernetes to install DefectDojo
614626
| django.nginx.containerSecurityContext.runAsUser | int | `1001` | |
615627
| django.nginx.extraEnv | list | `[]` | |
616628
| django.nginx.extraVolumeMounts | list | `[]` | |
629+
| django.nginx.image.digest | string | `""` | |
630+
| django.nginx.image.registry | string | `""` | |
631+
| django.nginx.image.repository | string | `""` | |
632+
| django.nginx.image.tag | string | `""` | |
617633
| django.nginx.resources.limits.cpu | string | `"2000m"` | |
618634
| django.nginx.resources.limits.memory | string | `"256Mi"` | |
619635
| django.nginx.resources.requests.cpu | string | `"100m"` | |
@@ -638,6 +654,10 @@ A Helm chart for Kubernetes to install DefectDojo
638654
| django.uwsgi.enableDebug | bool | `false` | |
639655
| django.uwsgi.extraEnv | list | `[]` | |
640656
| django.uwsgi.extraVolumeMounts | list | `[]` | |
657+
| django.uwsgi.image.digest | string | `""` | |
658+
| django.uwsgi.image.registry | string | `""` | |
659+
| django.uwsgi.image.repository | string | `""` | |
660+
| django.uwsgi.image.tag | string | `""` | |
641661
| django.uwsgi.livenessProbe.enabled | bool | `true` | |
642662
| django.uwsgi.livenessProbe.failureThreshold | int | `6` | |
643663
| django.uwsgi.livenessProbe.initialDelaySeconds | int | `0` | |
@@ -671,12 +691,24 @@ A Helm chart for Kubernetes to install DefectDojo
671691
| host | string | `"defectdojo.default.minikube.local"` | |
672692
| imagePullPolicy | string | `"Always"` | |
673693
| imagePullSecrets | string | `nil` | |
694+
| images.django.image.digest | string | `""` | |
695+
| images.django.image.registry | string | `""` | |
696+
| images.django.image.repository | string | `"defectdojo/defectdojo-django"` | |
697+
| images.django.image.tag | string | `""` | |
698+
| images.nginx.image.digest | string | `""` | |
699+
| images.nginx.image.registry | string | `""` | |
700+
| images.nginx.image.repository | string | `"defectdojo/defectdojo-nginx"` | |
701+
| images.nginx.image.tag | string | `""` | |
674702
| initializer.affinity | object | `{}` | |
675703
| initializer.annotations | object | `{}` | |
676704
| initializer.containerSecurityContext | object | `{}` | |
677705
| initializer.extraEnv | list | `[]` | |
678706
| initializer.extraVolumeMounts | list | `[]` | |
679707
| initializer.extraVolumes | list | `[]` | |
708+
| initializer.image.digest | string | `""` | |
709+
| initializer.image.registry | string | `""` | |
710+
| initializer.image.repository | string | `""` | |
711+
| initializer.image.tag | string | `""` | |
680712
| initializer.jobAnnotations | object | `{}` | |
681713
| initializer.keepSeconds | int | `60` | |
682714
| initializer.labels | object | `{}` | |
@@ -695,7 +727,10 @@ A Helm chart for Kubernetes to install DefectDojo
695727
| monitoring.prometheus.enabled | bool | `false` | |
696728
| monitoring.prometheus.extraEnv | list | `[]` | |
697729
| monitoring.prometheus.extraVolumeMounts | list | `[]` | |
698-
| monitoring.prometheus.image | string | `"nginx/nginx-prometheus-exporter:1.4.2"` | |
730+
| monitoring.prometheus.image.digest | string | `""` | |
731+
| monitoring.prometheus.image.registry | string | `""` | |
732+
| monitoring.prometheus.image.repository | string | `"nginx/nginx-prometheus-exporter"` | |
733+
| monitoring.prometheus.image.tag | string | `"1.4.2"` | |
699734
| monitoring.prometheus.imagePullPolicy | string | `"IfNotPresent"` | |
700735
| monitoring.prometheus.resources | object | `{}` | |
701736
| networkPolicy.annotations | object | `{}` | |
@@ -735,7 +770,6 @@ A Helm chart for Kubernetes to install DefectDojo
735770
| redis.tls.enabled | bool | `false` | |
736771
| redisParams | string | `""` | |
737772
| redisServer | string | `nil` | |
738-
| repositoryPrefix | string | `"defectdojo"` | |
739773
| revisionHistoryLimit | int | `10` | |
740774
| secrets.annotations | object | `{}` | |
741775
| securityContext.containerSecurityContext.runAsNonRoot | bool | `true` | |
@@ -746,7 +780,10 @@ A Helm chart for Kubernetes to install DefectDojo
746780
| serviceAccount.labels | object | `{}` | |
747781
| serviceAccount.name | string | `""` | |
748782
| siteUrl | string | `""` | |
749-
| tag | string | `"latest"` | |
783+
| tests.unitTests.image.digest | string | `""` | |
784+
| tests.unitTests.image.registry | string | `""` | |
785+
| tests.unitTests.image.repository | string | `""` | |
786+
| tests.unitTests.image.tag | string | `""` | |
750787
| tests.unitTests.resources.limits.cpu | string | `"500m"` | |
751788
| tests.unitTests.resources.limits.memory | string | `"512Mi"` | |
752789
| tests.unitTests.resources.requests.cpu | string | `"100m"` | |

helm/defectdojo/templates/_helpers.tpl

Lines changed: 53 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,20 +85,64 @@
8585
{{- /*
8686
Builds the repository names for use with local or private registries
8787
*/}}
88-
{{- define "celery.repository" -}}
89-
{{- printf "%s" .Values.repositoryPrefix -}}/defectdojo-django
88+
{{- define "celery.beat.image" -}}
89+
{{ include "images.image" (dict "imageRoot" (merge .Values.celery.beat.image .Values.images.django.image) "global" .Values.global "chart" .Chart ) }}
9090
{{- end -}}
9191

92-
{{- define "django.nginx.repository" -}}
93-
{{- printf "%s" .Values.repositoryPrefix -}}/defectdojo-nginx
92+
{{- define "celery.worker.image" -}}
93+
{{ include "images.image" (dict "imageRoot" (merge .Values.celery.worker.image .Values.images.django.image) "global" .Values.global "chart" .Chart ) }}
9494
{{- end -}}
9595

96-
{{- define "django.uwsgi.repository" -}}
97-
{{- printf "%s" .Values.repositoryPrefix -}}/defectdojo-django
96+
{{- define "django.nginx.image" -}}
97+
{{ include "images.image" (dict "imageRoot" (merge .Values.django.nginx.image .Values.images.nginx.image) "global" .Values.global "chart" .Chart ) }}
9898
{{- end -}}
9999

100-
{{- define "initializer.repository" -}}
101-
{{- printf "%s" .Values.repositoryPrefix -}}/defectdojo-django
100+
{{- define "django.uwsgi.image" -}}
101+
{{ include "images.image" (dict "imageRoot" (merge .Values.django.uwsgi.image .Values.images.django.image) "global" .Values.global "chart" .Chart ) }}
102+
{{- end -}}
103+
104+
{{- define "initializer.image" -}}
105+
{{ include "images.image" (dict "imageRoot" (merge .Values.initializer.image .Values.images.django.image) "global" .Values.global "chart" .Chart ) }}
106+
{{- end -}}
107+
108+
{{- define "dbMigrationChecker.image" -}}
109+
{{ include "images.image" (dict "imageRoot" (merge .Values.dbMigrationChecker.image .Values.images.django.image) "global" .Values.global "chart" .Chart ) }}
110+
{{- end -}}
111+
112+
{{- define "unitTests.image" -}}
113+
{{ include "images.image" (dict "imageRoot" (merge .Values.tests.unitTests.image .Values.images.django.image) "global" .Values.global "chart" .Chart ) }}
114+
{{- end -}}
115+
116+
{{- define "monitoring.prometheus.image" -}}
117+
{{ include "images.image" (dict "imageRoot" .Values.monitoring.prometheus.image "global" .Values.global ) }}
118+
{{- end -}}
119+
120+
{{- /*
121+
Return the proper image name.
122+
If image tag and digest are not defined, termination fallbacks to chart appVersion.
123+
{{ include "images.image" ( dict "imageRoot" .Values.path.to.the.image "global" .Values.global "chart" .Chart ) }}
124+
Inspired by Bitnami Common Chart v2.31.7
125+
*/}}
126+
{{- define "images.image" -}}
127+
{{- $registryName := default .imageRoot.registry ((.global).imageRegistry) -}}
128+
{{- $repositoryName := .imageRoot.repository -}}
129+
{{- $separator := ":" -}}
130+
{{- $termination := .imageRoot.tag | toString -}}
131+
132+
{{- if not .imageRoot.tag }}
133+
{{- if .chart }}
134+
{{- $termination = .chart.AppVersion | toString -}}
135+
{{- end -}}
136+
{{- end -}}
137+
{{- if .imageRoot.digest }}
138+
{{- $separator = "@" -}}
139+
{{- $termination = .imageRoot.digest | toString -}}
140+
{{- end -}}
141+
{{- if $registryName }}
142+
{{- printf "%s/%s%s%s" $registryName $repositoryName $separator $termination -}}
143+
{{- else -}}
144+
{{- printf "%s%s%s" $repositoryName $separator $termination -}}
145+
{{- end -}}
102146
{{- end -}}
103147

104148
{{- define "initializer.jobname" -}}
@@ -141,7 +185,7 @@
141185
- sh
142186
- -c
143187
- while ! /app/manage.py migrate --check; do echo "Database is not migrated to the latest state yet"; sleep 5; done; echo "Database is migrated to the latest state";
144-
image: '{{ template "django.uwsgi.repository" . }}:{{ .Values.tag }}'
188+
image: '{{ template "dbMigrationChecker.image" . }}'
145189
imagePullPolicy: {{ .Values.imagePullPolicy }}
146190
{{- if .Values.securityContext.enabled }}
147191
securityContext:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ spec:
9898
- command:
9999
- /entrypoint-celery-beat.sh
100100
name: celery
101-
image: "{{ template "celery.repository" . }}:{{ .Values.tag }}"
101+
image: "{{ template "celery.beat.image" . }}"
102102
imagePullPolicy: {{ .Values.imagePullPolicy }}
103103
{{- with .Values.celery.beat.livenessProbe }}
104104
livenessProbe: {{ toYaml . | nindent 10 }}

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ spec:
9494
{{- end }}
9595
containers:
9696
- name: celery
97-
image: "{{ template "celery.repository" . }}:{{ .Values.tag }}"
97+
image: "{{ template "celery.worker.image" . }}"
9898
imagePullPolicy: {{ .Values.imagePullPolicy }}
9999
{{- with .Values.celery.worker.livenessProbe }}
100100
livenessProbe: {{ toYaml . | nindent 10 }}

helm/defectdojo/templates/django-deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ spec:
115115
containers:
116116
{{- if and .Values.monitoring.enabled .Values.monitoring.prometheus.enabled }}
117117
- name: metrics
118-
image: {{ .Values.monitoring.prometheus.image }}
118+
image: '{{ template "monitoring.prometheus.image" . }}'
119119
imagePullPolicy: {{ .Values.monitoring.prometheus.imagePullPolicy }}
120120
command:
121121
- /usr/bin/nginx-prometheus-exporter
@@ -151,7 +151,7 @@ spec:
151151
{{- end }}
152152
{{- end }}
153153
- name: uwsgi
154-
image: '{{ template "django.uwsgi.repository" . }}:{{ .Values.tag }}'
154+
image: '{{ template "django.uwsgi.image" . }}'
155155
imagePullPolicy: {{ .Values.imagePullPolicy }}
156156
{{- if .Values.securityContext.enabled }}
157157
securityContext:
@@ -253,7 +253,7 @@ spec:
253253
resources:
254254
{{- toYaml .Values.django.uwsgi.resources | nindent 10 }}
255255
- name: nginx
256-
image: '{{ template "django.nginx.repository" . }}:{{ .Values.tag }}'
256+
image: '{{ template "django.nginx.image" . }}'
257257
imagePullPolicy: {{ .Values.imagePullPolicy }}
258258
{{- if .Values.securityContext.enabled }}
259259
securityContext:

helm/defectdojo/templates/initializer-job.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ spec:
8181
- '/bin/bash'
8282
- '-c'
8383
- '/wait-for-it.sh ${DD_DATABASE_HOST:-postgres}:${DD_DATABASE_PORT:-5432} -t 300 -s -- /bin/echo Database is up'
84-
image: '{{ template "django.uwsgi.repository" . }}:{{ .Values.tag }}'
84+
image: "{{ template "initializer.image" . }}"
8585
imagePullPolicy: {{ .Values.imagePullPolicy }}
8686
{{- if .Values.securityContext.enabled }}
8787
securityContext:
@@ -112,7 +112,7 @@ spec:
112112
{{- end }}
113113
containers:
114114
- name: initializer
115-
image: "{{ template "initializer.repository" . }}:{{ .Values.tag }}"
115+
image: "{{ template "initializer.image" . }}"
116116
imagePullPolicy: {{ .Values.imagePullPolicy }}
117117
{{- if .Values.securityContext.enabled }}
118118
securityContext:

0 commit comments

Comments
 (0)