Skip to content

Commit

Permalink
fixes the secret handling
Browse files Browse the repository at this point in the history
you either have to configure a dockerjsonconfig or a global.imagepullsecrets

but when you configure both, both are added to the imagepullsecrets in the deployments and stateful-sets
  • Loading branch information
unglaublicherdude committed Jun 26, 2024
1 parent 76e5e3d commit aa1c0fd
Show file tree
Hide file tree
Showing 7 changed files with 50 additions and 17 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,4 +8,5 @@
*.tgz
.fleet/
.output/
Chart.lock
Chart.lock
tmp/
2 changes: 1 addition & 1 deletion charts/vaas/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: vaas
version: 1.8.0
version: 1.9.0
description: Deployment of a Verdict-as-a-Service on-premise instance
maintainers:
- name: G DATA CyberDefense AG
Expand Down
11 changes: 7 additions & 4 deletions charts/vaas/templates/gateway/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,17 @@ If release name contains chart name it will be used as a full name.
{{- end }}

{{- define "gateway.imagePullSecrets" -}}
{{- if or (gt (len .Values.global.imagePullSecrets) 0) (.Values.global.secret.dockerconfigjson) -}}
imagePullSecrets:
{{- range .Values.global.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- if .Values.imagePullSecret }}
- name: {{ .Release.Name }}-registry-secret
{{- end }}
{{- end -}}
{{- if (.Values.global.secret).dockerconfigjson }}
- name: registry
{{- end -}}
{{- end -}}
{{ end -}}


{{/*
Create chart name and version as used by the chart label.
Expand Down
16 changes: 14 additions & 2 deletions charts/vaas/templates/gateway/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
{{- if .Values.global.imagePullSecrets }}
{{- if and (not .Values.global.imagePullSecrets) (not .Values.global.imagePullSecret)}}
apiVersion: v1
kind: Secret
metadata:
name: registry
namespace: {{ .Release.Namespace }}
data:
.dockerconfigjson: {{ required "You need to set the dockerconfigjson for the private registry" .Values.global.secret.dockerconfigjson }}
.dockerconfigjson: {{ required "You need to set the dockerconfigjson for the private registry" (.Values.global.secret).dockerconfigjson }}
type: kubernetes.io/dockerconfigjson
{{- end -}}
{{- if or (.Values.global.imagePullSecrets) (.Values.global.imagePullSecret)}}
{{- if (.Values.global.secret).dockerconfigjson }}
apiVersion: v1
kind: Secret
metadata:
name: registry
namespace: {{ .Release.Namespace }}
data:
.dockerconfigjson: {{ .Values.global.secret.dockerconfigjson }}
type: kubernetes.io/dockerconfigjson
{{- end -}}
{{- end -}}
18 changes: 11 additions & 7 deletions charts/vaas/templates/gdscan/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,19 @@ app.kubernetes.io/managed-by: {{ .Release.Service }}
{{- end }}

{{- define "gdscan.imagePullSecrets" -}}

{{- $imagePullSecrets := concat (((.Values.global | default dict).imagePullSecrets)| default list) (.Values.gdscan.imagePullSecrets | default list) -}}
{{- if gt (len $imagePullSecrets) 0 -}}
{{- if or (gt (len .Values.global.imagePullSecrets) 0) (gt (len .Values.gdscan.imagePullSecrets) 0) ((.Values.global.secret).dockerconfigjson) -}}
imagePullSecrets:
{{- range $imagePullSecrets }}
{{- range .Values.global.imagePullSecrets }}
- name: {{ . }}
{{- end }}
{{- end }}
{{- end }}
{{- end -}}
{{- range .Values.gdscan.imagePullSecrets }}
- name: {{ . }}
{{- end -}}
{{- if (.Values.global.secret).dockerconfigjson }}
- name: gdscanregistry
{{- end -}}
{{- end -}}
{{ end -}}

{{/*
Selector labels
Expand Down
16 changes: 14 additions & 2 deletions charts/vaas/templates/gdscan/secret.yaml
Original file line number Diff line number Diff line change
@@ -1,10 +1,22 @@
{{- if .Values.global.imagePullSecrets }}
{{- if and (not .Values.global.imagePullSecrets) (not .Values.global.imagePullSecret) (not .Values.gdscan.imagePullSecret)}}
apiVersion: v1
kind: Secret
metadata:
name: gdscanregistry
namespace: {{ .Release.Namespace }}
data:
.dockerconfigjson: {{ required "You need to set the dockerconfigjson for the private registry" .Values.global.secret.dockerconfigjson }}
.dockerconfigjson: {{ required "You need to set the dockerconfigjson for the private registry" (.Values.global.secret).dockerconfigjson }}
type: kubernetes.io/dockerconfigjson
{{- end -}}
{{- if or (.Values.global.imagePullSecrets) (.Values.global.imagePullSecret)}}
{{- if (.Values.global.secret).dockerconfigjson }}
apiVersion: v1
kind: Secret
metadata:
name: gdscanregistry
namespace: {{ .Release.Namespace }}
data:
.dockerconfigjson: {{ .Values.global.secret.dockerconfigjson }}
type: kubernetes.io/dockerconfigjson
{{- end -}}
{{- end -}}
1 change: 1 addition & 0 deletions charts/vaas/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ gateway:
gdscanUrl: "http://gdscan:8080/scan/body"

gdscan:
imagePullSecrets: []
replicaCount: 1
deploymentStrategy: "RollingUpdate"
client:
Expand Down

0 comments on commit aa1c0fd

Please sign in to comment.