Skip to content

Commit f0332bf

Browse files
committed
feat(helm): Split image locations+tags, allow digest pinning
1 parent 4d2fe44 commit f0332bf

13 files changed

Lines changed: 351 additions & 43 deletions

File tree

.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.2-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.2-dev](https://img.shields.io/badge/Version-1.7.2--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
@@ -534,6 +534,10 @@ A Helm chart for Kubernetes to install DefectDojo
534534
| celery.beat.extraInitContainers | list | `[]` | |
535535
| celery.beat.extraVolumeMounts | list | `[]` | |
536536
| celery.beat.extraVolumes | list | `[]` | |
537+
| celery.beat.image.digest | string | `""` | |
538+
| celery.beat.image.registry | string | `""` | |
539+
| celery.beat.image.repository | string | `""` | |
540+
| celery.beat.image.tag | string | `""` | |
537541
| celery.beat.livenessProbe | object | `{}` | |
538542
| celery.beat.nodeSelector | object | `{}` | |
539543
| celery.beat.podAnnotations | object | `{}` | |
@@ -557,6 +561,10 @@ A Helm chart for Kubernetes to install DefectDojo
557561
| celery.worker.extraInitContainers | list | `[]` | |
558562
| celery.worker.extraVolumeMounts | list | `[]` | |
559563
| celery.worker.extraVolumes | list | `[]` | |
564+
| celery.worker.image.digest | string | `""` | |
565+
| celery.worker.image.registry | string | `""` | |
566+
| celery.worker.image.repository | string | `""` | |
567+
| celery.worker.image.tag | string | `""` | |
560568
| celery.worker.livenessProbe | object | `{}` | |
561569
| celery.worker.nodeSelector | object | `{}` | |
562570
| celery.worker.podAnnotations | object | `{}` | |
@@ -588,6 +596,10 @@ A Helm chart for Kubernetes to install DefectDojo
588596
| dbMigrationChecker.enabled | bool | `true` | |
589597
| dbMigrationChecker.extraEnv | list | `[]` | |
590598
| dbMigrationChecker.extraVolumeMounts | list | `[]` | |
599+
| dbMigrationChecker.image.digest | string | `""` | |
600+
| dbMigrationChecker.image.registry | string | `""` | |
601+
| dbMigrationChecker.image.repository | string | `""` | |
602+
| dbMigrationChecker.image.tag | string | `""` | |
591603
| dbMigrationChecker.resources.limits.cpu | string | `"200m"` | |
592604
| dbMigrationChecker.resources.limits.memory | string | `"200Mi"` | |
593605
| dbMigrationChecker.resources.requests.cpu | string | `"100m"` | |
@@ -617,6 +629,10 @@ A Helm chart for Kubernetes to install DefectDojo
617629
| django.nginx.containerSecurityContext.runAsUser | int | `1001` | |
618630
| django.nginx.extraEnv | list | `[]` | |
619631
| django.nginx.extraVolumeMounts | list | `[]` | |
632+
| django.nginx.image.digest | string | `""` | |
633+
| django.nginx.image.registry | string | `""` | |
634+
| django.nginx.image.repository | string | `""` | |
635+
| django.nginx.image.tag | string | `""` | |
620636
| django.nginx.resources.limits.cpu | string | `"2000m"` | |
621637
| django.nginx.resources.limits.memory | string | `"256Mi"` | |
622638
| django.nginx.resources.requests.cpu | string | `"100m"` | |
@@ -641,6 +657,10 @@ A Helm chart for Kubernetes to install DefectDojo
641657
| django.uwsgi.enableDebug | bool | `false` | |
642658
| django.uwsgi.extraEnv | list | `[]` | |
643659
| django.uwsgi.extraVolumeMounts | list | `[]` | |
660+
| django.uwsgi.image.digest | string | `""` | |
661+
| django.uwsgi.image.registry | string | `""` | |
662+
| django.uwsgi.image.repository | string | `""` | |
663+
| django.uwsgi.image.tag | string | `""` | |
644664
| django.uwsgi.livenessProbe.enabled | bool | `true` | |
645665
| django.uwsgi.livenessProbe.failureThreshold | int | `6` | |
646666
| django.uwsgi.livenessProbe.initialDelaySeconds | int | `0` | |
@@ -674,13 +694,25 @@ A Helm chart for Kubernetes to install DefectDojo
674694
| host | string | `"defectdojo.default.minikube.local"` | |
675695
| imagePullPolicy | string | `"Always"` | |
676696
| imagePullSecrets | string | `nil` | |
697+
| images.django.image.digest | string | `""` | |
698+
| images.django.image.registry | string | `""` | |
699+
| images.django.image.repository | string | `"defectdojo/defectdojo-django"` | |
700+
| images.django.image.tag | string | `""` | |
701+
| images.nginx.image.digest | string | `""` | |
702+
| images.nginx.image.registry | string | `""` | |
703+
| images.nginx.image.repository | string | `"defectdojo/defectdojo-nginx"` | |
704+
| images.nginx.image.tag | string | `""` | |
677705
| initializer.affinity | object | `{}` | |
678706
| initializer.annotations | object | `{}` | |
679707
| initializer.automountServiceAccountToken | bool | `false` | |
680708
| initializer.containerSecurityContext | object | `{}` | |
681709
| initializer.extraEnv | list | `[]` | |
682710
| initializer.extraVolumeMounts | list | `[]` | |
683711
| initializer.extraVolumes | list | `[]` | |
712+
| initializer.image.digest | string | `""` | |
713+
| initializer.image.registry | string | `""` | |
714+
| initializer.image.repository | string | `""` | |
715+
| initializer.image.tag | string | `""` | |
684716
| initializer.jobAnnotations | object | `{}` | |
685717
| initializer.keepSeconds | int | `60` | |
686718
| initializer.labels | object | `{}` | |
@@ -699,7 +731,10 @@ A Helm chart for Kubernetes to install DefectDojo
699731
| monitoring.prometheus.enabled | bool | `false` | |
700732
| monitoring.prometheus.extraEnv | list | `[]` | |
701733
| monitoring.prometheus.extraVolumeMounts | list | `[]` | |
702-
| monitoring.prometheus.image | string | `"nginx/nginx-prometheus-exporter:1.4.2"` | |
734+
| monitoring.prometheus.image.digest | string | `""` | |
735+
| monitoring.prometheus.image.registry | string | `""` | |
736+
| monitoring.prometheus.image.repository | string | `"nginx/nginx-prometheus-exporter"` | |
737+
| monitoring.prometheus.image.tag | string | `"1.4.2"` | |
703738
| monitoring.prometheus.imagePullPolicy | string | `"IfNotPresent"` | |
704739
| monitoring.prometheus.resources | object | `{}` | |
705740
| networkPolicy.annotations | object | `{}` | |
@@ -739,7 +774,6 @@ A Helm chart for Kubernetes to install DefectDojo
739774
| redis.tls.enabled | bool | `false` | |
740775
| redisParams | string | `""` | |
741776
| redisServer | string | `nil` | |
742-
| repositoryPrefix | string | `"defectdojo"` | |
743777
| revisionHistoryLimit | int | `10` | |
744778
| secrets.annotations | object | `{}` | |
745779
| securityContext.containerSecurityContext.runAsNonRoot | bool | `true` | |
@@ -750,8 +784,11 @@ A Helm chart for Kubernetes to install DefectDojo
750784
| serviceAccount.labels | object | `{}` | |
751785
| serviceAccount.name | string | `""` | |
752786
| siteUrl | string | `""` | |
753-
| tag | string | `"latest"` | |
754787
| tests.unitTests.automountServiceAccountToken | bool | `false` | |
788+
| tests.unitTests.image.digest | string | `""` | |
789+
| tests.unitTests.image.registry | string | `""` | |
790+
| tests.unitTests.image.repository | string | `""` | |
791+
| tests.unitTests.image.tag | string | `""` | |
755792
| tests.unitTests.resources.limits.cpu | string | `"500m"` | |
756793
| tests.unitTests.resources.limits.memory | string | `"512Mi"` | |
757794
| 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
@@ -99,7 +99,7 @@ spec:
9999
- command:
100100
- /entrypoint-celery-beat.sh
101101
name: celery
102-
image: "{{ template "celery.repository" . }}:{{ .Values.tag }}"
102+
image: "{{ template "celery.beat.image" . }}"
103103
imagePullPolicy: {{ .Values.imagePullPolicy }}
104104
{{- with .Values.celery.beat.livenessProbe }}
105105
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
@@ -95,7 +95,7 @@ spec:
9595
{{- end }}
9696
containers:
9797
- name: celery
98-
image: "{{ template "celery.repository" . }}:{{ .Values.tag }}"
98+
image: "{{ template "celery.worker.image" . }}"
9999
imagePullPolicy: {{ .Values.imagePullPolicy }}
100100
{{- with .Values.celery.worker.livenessProbe }}
101101
livenessProbe: {{ toYaml . | nindent 10 }}

helm/defectdojo/templates/django-deployment.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ spec:
116116
containers:
117117
{{- if and .Values.monitoring.enabled .Values.monitoring.prometheus.enabled }}
118118
- name: metrics
119-
image: {{ .Values.monitoring.prometheus.image }}
119+
image: '{{ template "monitoring.prometheus.image" . }}'
120120
imagePullPolicy: {{ .Values.monitoring.prometheus.imagePullPolicy }}
121121
command:
122122
- /usr/bin/nginx-prometheus-exporter
@@ -152,7 +152,7 @@ spec:
152152
{{- end }}
153153
{{- end }}
154154
- name: uwsgi
155-
image: '{{ template "django.uwsgi.repository" . }}:{{ .Values.tag }}'
155+
image: '{{ template "django.uwsgi.image" . }}'
156156
imagePullPolicy: {{ .Values.imagePullPolicy }}
157157
{{- if .Values.securityContext.enabled }}
158158
securityContext:
@@ -254,7 +254,7 @@ spec:
254254
resources:
255255
{{- toYaml .Values.django.uwsgi.resources | nindent 10 }}
256256
- name: nginx
257-
image: '{{ template "django.nginx.repository" . }}:{{ .Values.tag }}'
257+
image: '{{ template "django.nginx.image" . }}'
258258
imagePullPolicy: {{ .Values.imagePullPolicy }}
259259
{{- if .Values.securityContext.enabled }}
260260
securityContext:

helm/defectdojo/templates/initializer-job.yaml

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

0 commit comments

Comments
 (0)