blob: e1387ae30f4f64a65952c69375f4cd5a5dc41f4e [file] [log] [blame]
Andreas Geisslercde4a782024-02-28 16:08:06 +01001{{- /*
2Copyright VMware, Inc.
3SPDX-License-Identifier: APACHE-2.0
4*/}}
5
6{{- if (include "mongodb.createTlsSecret" .) }}
7{{- $secretName := printf "%s" (include "mongodb.tlsSecretName" .) }}
8{{- $fullname := include "mongodb.fullname" . }}
9{{- $releaseNamespace := .Release.Namespace }}
10{{- $clusterDomain := .Values.clusterDomain }}
11{{- $cn := printf "%s.%s.svc.%s" $fullname .Release.Namespace $clusterDomain }}
12apiVersion: v1
13kind: Secret
14metadata:
15 name: {{ $secretName }}
16 namespace: {{ template "mongodb.namespace" . }}
17 labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
18 app.kubernetes.io/component: mongodb
19 {{- if .Values.commonAnnotations }}
20 annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
21 {{- end }}
22type: Opaque
23data:
24 {{- if or .Values.tls.caCert .Values.tls.caKey (not .Values.tls.autoGenerated) }}
25 {{- $ca := buildCustomCert (required "A valid .Values.tls.caCert is required!" .Values.tls.caCert) (required "A valid .Values.tls.caKey is required!" .Values.tls.caKey) }}
26 mongodb-ca-cert: {{ b64enc $ca.Cert }}
27 mongodb-ca-key: {{ b64enc $ca.Key }}
28 {{- else }}
29 {{- $ca := genCA "myMongo-ca" 3650 }}
30 mongodb-ca-cert: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "mongodb-ca-cert" "defaultValue" $ca.Cert "context" $) }}
31 mongodb-ca-key: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "mongodb-ca-key" "defaultValue" $ca.Key "context" $) }}
32 {{- end }}
33{{- end }}