# helm_charts_default-cert-secret.yaml
{{- if .Values.ssl.enabled }}
apiVersion: v1
kind: Secret
metadata:
  name: {{ template "traefik.fullname" . }}-default-cert
  labels:
    app: {{ template "traefik.name" . }}
    chart: {{ template "traefik.chart" . }}
    release: {{ .Release.Name | quote }}
    heritage: {{ .Release.Service | quote }}
type: Opaque
data:
{{- if .Values.ssl.generateTLS }}
  {{- $ca := genCA "default-ca" 365 }}
  {{- $cn := default "example.com" .Values.ssl.defaultCN }}
  {{- $server := genSignedCert $cn ( default nil .Values.ssl.defaultIPList ) ( default nil .Values.ssl.defaultSANList ) 365 $ca }}
  tls.crt: {{ $server.Cert | b64enc }}
  tls.key: {{ $server.Key | b64enc }}
{{- else }}
  tls.crt: {{ .Values.ssl.defaultCert }}
  tls.key: {{ .Values.ssl.defaultKey }}
{{- end }}
{{- end }}