Skip to content

Commit

Permalink
External secret for email password (#426)
Browse files Browse the repository at this point in the history
Co-authored-by: Léo Colombaro <[email protected]>
  • Loading branch information
KittyKatt and LeoColomb authored Dec 6, 2024
1 parent 8ae7ad7 commit 7281991
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 7 deletions.
2 changes: 1 addition & 1 deletion charts/netbox/Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
apiVersion: v2
name: netbox
version: 5.0.0-beta.157
version: 5.0.0-beta.158
appVersion: "v4.1.7"
type: application
kubeVersion: ^1.25.0-0
Expand Down
11 changes: 11 additions & 0 deletions charts/netbox/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,17 @@ Create the name of the service account to use
{{- end }}
{{- end }}

{{/*
Name of the key in Secret that contains the email password
*/}}
{{- define "netbox.email.secretKey" -}}
{{- if .Values.email.existingSecretName -}}
{{- .Values.email.existingSecretKey -}}
{{- else -}}
email_password
{{- end -}}
{{- end }}

{{/*
Name of the Secret that contains the PostgreSQL password
*/}}
Expand Down
7 changes: 5 additions & 2 deletions charts/netbox/templates/cronjob.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,17 @@ spec:
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.existingSecret "defaultNameSuffix" "config" "context" $) }}
items:
- key: email_password
path: email_password
- key: secret_key
path: secret_key
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" (default .Values.email.existingSecretName .Values.existingSecret) "defaultNameSuffix" "config" "context" $) }}
items:
- key: {{ include "netbox.email.secretKey" . | quote }}
path: email_password
- secret:
name: {{ include "netbox.postgresql.secret" . | quote }}
items:
Expand Down
7 changes: 5 additions & 2 deletions charts/netbox/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,14 +224,17 @@ spec:
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.existingSecret "defaultNameSuffix" "config" "context" $) }}
items:
- key: email_password
path: email_password
- key: secret_key
path: secret_key
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" (default .Values.email.existingSecretName .Values.existingSecret) "defaultNameSuffix" "config" "context" $) }}
items:
- key: {{ include "netbox.email.secretKey" . | quote }}
path: email_password
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.superuser.existingSecret "defaultNameSuffix" "superuser" "context" $) }}
items:
Expand Down
2 changes: 2 additions & 0 deletions charts/netbox/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@ metadata:
{{- end }}
type: Opaque
data:
{{- if not .Values.email.existingSecretName }}
email_password: {{ .Values.email.password | b64enc | quote }}
{{- end }}
secret_key: {{ .Values.secretKey | default (randAscii 60) | b64enc | quote }}
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
ldap_bind_password: {{ .Values.remoteAuth.ldap.bindPassword | b64enc | quote }}
Expand Down
7 changes: 5 additions & 2 deletions charts/netbox/templates/worker/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -132,14 +132,17 @@ spec:
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.existingSecret "defaultNameSuffix" "config" "context" $) }}
items:
- key: email_password
path: email_password
- key: secret_key
path: secret_key
{{- if has "netbox.authentication.LDAPBackend" .Values.remoteAuth.backends }}
- key: ldap_bind_password
path: ldap_bind_password
{{- end }}
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" (default .Values.email.existingSecretName .Values.existingSecret) "defaultNameSuffix" "config" "context" $) }}
items:
- key: {{ include "netbox.email.secretKey" . | quote }}
path: email_password
- secret:
name: {{ include "common.secrets.name" (dict "existingSecret" .Values.superuser.existingSecret "defaultNameSuffix" "superuser" "context" $) }}
items:
Expand Down
2 changes: 2 additions & 0 deletions charts/netbox/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,8 @@ email:
# Timeout in seconds
timeout: 10
from: ""
existingSecretName: ""
existingSecretKey: email-password

# Enforcement of unique IP space can be toggled on a per-VRF basis. To enforce
# unique IP space within the global table (all prefixes and IP addresses not
Expand Down

0 comments on commit 7281991

Please sign in to comment.