Skip to content

Commit

Permalink
feat: add the extra labels capabilities for chart
Browse files Browse the repository at this point in the history
Signed-off-by: Julien Godin <[email protected]>
  • Loading branch information
JGodin-C2C committed Nov 1, 2024
1 parent e24aa1b commit 4f468e6
Show file tree
Hide file tree
Showing 17 changed files with 92 additions and 26 deletions.
14 changes: 10 additions & 4 deletions helm/defectdojo/templates/celery-beat-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.celery.beat.replicas }}
{{- if .Values.revisionHistoryLimit }}
Expand All @@ -28,8 +31,11 @@ spec:
defectdojo.org/subcomponent: beat
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- with .Values.celery.beat.annotations }}
Expand Down Expand Up @@ -143,8 +149,8 @@ spec:
secretKeyRef:
name: {{ $fullName }}
key: DD_SECRET_KEY
{{- if .Values.extraEnv }}
{{- toYaml .Values.extraEnv | nindent 8 }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.celery.beat.resources | nindent 10 }}
Expand Down
14 changes: 10 additions & 4 deletions helm/defectdojo/templates/celery-worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.celery.worker.replicas }}
{{- if .Values.revisionHistoryLimit }}
Expand All @@ -28,8 +31,11 @@ spec:
defectdojo.org/subcomponent: worker
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- with .Values.celery.worker.annotations }}
Expand Down Expand Up @@ -138,8 +144,8 @@ spec:
secretKeyRef:
name: {{ $fullName }}
key: DD_SECRET_KEY
{{- if .Values.extraEnv }}
{{- toYaml .Values.extraEnv | nindent 8 }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.celery.worker.resources | nindent 10 }}
Expand Down
7 changes: 5 additions & 2 deletions helm/defectdojo/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
data:
DD_ADMIN_USER: {{ .Values.admin.user | default "admin" }}
DD_ADMIN_MAIL: {{ .Values.admin.Mail | default "[email protected]" }}
Expand Down Expand Up @@ -45,5 +48,5 @@ data:
{{- if .Values.django.uwsgi.certificates.enabled }}
REQUESTS_CA_BUNDLE: {{ .Values.django.uwsgi.certificates.certMountPath }}{{ .Values.django.uwsgi.certificates.certFileName }}
{{- end }}
{{- if .Values.extraConfigs }}
{{ toYaml .Values.extraConfigs | indent 2 }}{{- end }}
{{- with .Values.extraConfigs }}
{{ toYaml . | nindent 2 }}{{- end }}
16 changes: 11 additions & 5 deletions helm/defectdojo/templates/django-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
replicas: {{ .Values.django.replicas }}
{{- if .Values.revisionHistoryLimit }}
Expand All @@ -25,9 +28,12 @@ spec:
defectdojo.org/component: django
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.podLabels }}
{{- toYaml .Values.podLabels | nindent 8 }}
{{- end }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.podLabels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- with .Values.django.annotations }}
{{- toYaml . | nindent 8 }}
Expand Down Expand Up @@ -202,8 +208,8 @@ spec:
value: {{- if or .Values.django.ingress.activateTLS .Values.django.nginx.tls.enabled }} "True" {{- else }} "False" {{- end }}
- name: DD_CSRF_COOKIE_SECURE
value: {{- if or .Values.django.ingress.activateTLS .Values.django.nginx.tls.enabled }} "True" {{- else }} "False" {{- end }}
{{- if .Values.extraEnv }}
{{- toYaml .Values.extraEnv | nindent 8 }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if .Values.django.uwsgi.livenessProbe.enabled }}
livenessProbe:
Expand Down
5 changes: 4 additions & 1 deletion helm/defectdojo/templates/django-ingress.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,13 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if or .Values.django.ingress.annotations .Values.gke.useGKEIngress }}
annotations:
{{- with .Values.django.ingress.annotations }}
{{ toYaml . | indent 4 }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.gke.useGKEIngress }}
kubernetes.io/ingress.class: gce
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/django-service.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
{{- if .Values.django.service.annotations }}
annotations:
{{- range $key, $value := .Values.django.service.annotations }}
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/extra-secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
type: Opaque
data:
{{- range $key, $value := .Values.extraSecrets }}
Expand Down
14 changes: 10 additions & 4 deletions helm/defectdojo/templates/initializer-job.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
{{- with .Values.initializer.jobAnnotations }}
{{- toYaml . | nindent 4 }}
Expand All @@ -22,8 +25,11 @@ spec:
defectdojo.org/component: initializer
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.initializer.labels }}
{{- toYaml .Values.initializer.labels | nindent 8 }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 8 }}
{{- end -}}
{{- with .Values.initializer.labels }}
{{- toYaml . | nindent 8 }}
{{- end }}
annotations:
{{- with .Values.initializer.annotations }}
Expand Down Expand Up @@ -118,8 +124,8 @@ spec:
name: {{ .Values.postgresqlha.postgresql.existingSecret }}
key: postgresql-postgres-password
{{- end }}
{{- if .Values.extraEnv }}
{{- toYaml .Values.extraEnv | nindent 8 }}
{{- with .Values.extraEnv }}
{{- toYaml . | nindent 8 }}
{{- end }}
resources:
{{- toYaml .Values.initializer.resources | nindent 10 }}
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/media-pvc.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@ metadata:
app.kubernetes.io/instance: {{ $.Release.Name }}
app.kubernetes.io/managed-by: {{ $.Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" $ }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
name: {{ $fullName }}
spec:
accessModes:
Expand Down
18 changes: 12 additions & 6 deletions helm/defectdojo/templates/network-policy.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,26 +9,29 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
podSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.networkPolicy.ingress}}
{{- if .Values.networkPolicy.ingress }}
ingress:
{{- toYaml .Values.networkPolicy.ingress | nindent 4 }}
{{- toYaml .Values.networkPolicy.ingress | nindent 4 }}
{{- else }}
ingress:
- from:
- podSelector:
matchLabels:
app.kubernetes.io/instance: {{ .Release.Name }}
{{- if .Values.networkPolicy.ingressExtend }}
{{- toYaml .Values.networkPolicy.ingressExtend | nindent 8 }}
{{- with .Values.networkPolicy.ingressExtend }}
{{- toYaml . | nindent 8 }}
{{ end }}
{{- end }}
{{- if .Values.networkPolicy.egress }}
{{- with .Values.networkPolicy.egress }}
egress:
{{- toYaml .Values.networkPolicy.egress | nindent 4 }}
{{- toYaml . | nindent 4 }}
{{ end }}
---
apiVersion: networking.k8s.io/v1
Expand All @@ -40,6 +43,9 @@ metadata:
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
app.kubernetes.io/name: {{ include "defectdojo.name" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
spec:
podSelector:
matchLabels:
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/sa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
helm.sh/hook: "pre-install"
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/secret-postgresql-ha-pgpool.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
helm.sh/hook: "pre-install"
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/secret-postgresql-ha.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
helm.sh/hook: "pre-install"
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/secret-postgresql.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
helm.sh/hook: "pre-install"
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/secret-redis.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
helm.sh/hook: "pre-install"
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@ metadata:
app.kubernetes.io/instance: {{ .Release.Name }}
app.kubernetes.io/managed-by: {{ .Release.Service }}
helm.sh/chart: {{ include "defectdojo.chart" . }}
{{- with .Values.extraLabels }}
{{- toYaml . | nindent 4 }}
{{- end }}
annotations:
helm.sh/resource-policy: keep
helm.sh/hook: "pre-install"
Expand Down
3 changes: 3 additions & 0 deletions helm/defectdojo/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ createPostgresqlHaPgpoolSecret: false
# - enabled, enables tracking configuration changes based on SHA256
# trackConfig: disabled

# extraLabels: {}
# Add extra labels for k8s

# Enables application network policy
# For more info follow https://kubernetes.io/docs/concepts/services-networking/network-policies/
networkPolicy:
Expand Down

0 comments on commit 4f468e6

Please sign in to comment.