aboutsummaryrefslogtreecommitdiffstats
path: root/kubernetes/common/nginx/templates/tls-secret.yaml
blob: 4a265f52430eeb41f5170fb16ac4234a3c338a6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if and .Values.tls.enabled (not .Values.tls.existingSecret) }}
{{- $ca := genCA "nginx-ca" 365 }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ printf "%s-tls" (include "common.names.fullname" .) }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
type: kubernetes.io/tls
data:
  {{- if .Values.tls.autoGenerated }}
  {{- $cert := genSignedCert (include "common.names.fullname" .) nil (list (include "common.names.fullname" .) (printf "%s.%s" (include "common.names.fullname" .) (include "common.names.namespace" .)) (printf "%s.%s.svc" (include "common.names.fullname" .) (include "common.names.namespace" .)) (printf "%s.%s.svc.%s" (include "common.names.fullname" .) (include "common.names.namespace" .) .Values.clusterDomain)) 365 $ca }}
  {{ .Values.tls.certFilename }}: {{ include "common.secrets.lookup" (dict "secret" (printf "%s-tls" (include "common.names.fullname" .)) "key" .Values.tls.certFilename "defaultValue" $cert.Cert "context" $) }}
  {{ .Values.tls.certKeyFilename }}: {{ include "common.secrets.lookup" (dict "secret" (printf "%s-tls" (include "common.names.fullname" .)) "key" .Values.tls.certKeyFilename "defaultValue" $cert.Key "context" $) }}
  {{ .Values.tls.certCAFilename }}: {{ include "common.secrets.lookup" (dict "secret" (printf "%s-tls" (include "common.names.fullname" .)) "key" .Values.tls.certCAFilename "defaultValue" $ca.Cert "context" $) }}
  {{- else }}
  {{- if .Values.tls.cert }}
  {{ .Values.tls.certFilename }}: {{ .Values.tls.cert | b64enc }}
  {{- end }}
  {{- if .Values.tls.key }}
  {{ .Values.tls.certKeyFilename }}: {{ .Values.tls.key | b64enc }}
  {{- end }}
  {{- if .Values.tls.ca }}
  {{ .Values.tls.certCAFilename }}: {{ .Values.tls.ca | b64enc }}
  {{- end }}
  {{- end }}
{{- end }}