tls-secrets.yaml 1.7 KB

123456789101112131415161718192021222324252627
  1. {{- if (include "postgresql.createTlsSecret" . ) }}
  2. {{- $ca := genCA "postgresql-ca" 365 }}
  3. {{- $fullname := include "common.names.fullname" . }}
  4. {{- $releaseNamespace := .Release.Namespace }}
  5. {{- $clusterDomain := .Values.clusterDomain }}
  6. {{- $primaryHeadlessServiceName := include "postgresql.primary.svc.headless" . }}
  7. {{- $readHeadlessServiceName := include "postgresql.readReplica.svc.headless" . }}
  8. {{- $altNames := list (printf "*.%s.%s.svc.%s" $fullname $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $fullname $releaseNamespace $clusterDomain) (printf "*.%s.%s.svc.%s" $primaryHeadlessServiceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $primaryHeadlessServiceName $releaseNamespace $clusterDomain) (printf "*.%s.%s.svc.%s" $readHeadlessServiceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $readHeadlessServiceName $releaseNamespace $clusterDomain) $fullname }}
  9. {{- $crt := genSignedCert $fullname nil $altNames 365 $ca }}
  10. apiVersion: v1
  11. kind: Secret
  12. metadata:
  13. name: {{ printf "%s-crt" (include "common.names.fullname" .) }}
  14. namespace: {{ .Release.Namespace | quote }}
  15. labels: {{- include "common.labels.standard" . | nindent 4 }}
  16. {{- if .Values.commonLabels }}
  17. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  18. {{- end }}
  19. {{- if .Values.commonAnnotations }}
  20. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  21. {{- end }}
  22. type: kubernetes.io/tls
  23. data:
  24. ca.crt: {{ $ca.Cert | b64enc | quote }}
  25. tls.crt: {{ $crt.Cert | b64enc | quote }}
  26. tls.key: {{ $crt.Key | b64enc | quote }}
  27. {{- end }}