tls-secret.yaml 1.7 KB

123456789101112131415161718192021222324252627
  1. {{- if (include "clickhouse.createTlsSecret" . ) }}
  2. {{- $secretName := printf "%s-crt" (include "common.names.fullname" .) }}
  3. {{- $ca := genCA "clickhouse-ca" 365 }}
  4. {{- $fullname := include "common.names.fullname" . }}
  5. {{- $releaseNamespace := .Release.Namespace }}
  6. {{- $clusterDomain := .Values.clusterDomain }}
  7. {{- $primaryHeadlessServiceName := printf "%s-headless" (include "common.names.fullname" .)}}
  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) $fullname }}
  9. {{- $cert := genSignedCert $fullname nil $altNames 365 $ca }}
  10. apiVersion: v1
  11. kind: Secret
  12. metadata:
  13. name: {{ $secretName }}
  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. tls.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.crt" "defaultValue" $cert.Cert "context" $) }}
  25. tls.key: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.key" "defaultValue" $cert.Key "context" $) }}
  26. ca.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "ca.crt" "defaultValue" $ca.Cert "context" $) }}
  27. {{- end }}