tls-secret.yaml 1.9 KB

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