tls-secrets.yaml 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. {{- /*
  2. Copyright Broadcom, Inc. All Rights Reserved.
  3. SPDX-License-Identifier: APACHE-2.0
  4. */}}
  5. {{- if (include "zookeeper.client.createTlsSecret" .) }}
  6. {{- $secretName := printf "%s-client-crt" (include "common.names.fullname" .) }}
  7. {{- $ca := genCA "zookeeper-client-ca" 365 }}
  8. {{- $releaseNamespace := .Release.Namespace }}
  9. {{- $clusterDomain := .Values.clusterDomain }}
  10. {{- $fullname := include "common.names.fullname" . }}
  11. {{- $serviceName := include "common.names.fullname" . }}
  12. {{- $headlessServiceName := printf "%s-headless" (include "common.names.fullname" .) }}
  13. {{- $altNames := list (printf "*.%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) (printf "*.%s.%s.svc.%s" $serviceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $serviceName $releaseNamespace $clusterDomain) "127.0.0.1" "localhost" $fullname }}
  14. {{- $cert := genSignedCert $fullname nil $altNames 365 $ca }}
  15. apiVersion: v1
  16. kind: Secret
  17. metadata:
  18. name: {{ $secretName }}
  19. namespace: {{ template "zookeeper.namespace" . }}
  20. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  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 }}
  30. {{- if (include "zookeeper.quorum.createTlsSecret" .) }}
  31. {{- $secretName := printf "%s-quorum-crt" (include "common.names.fullname" .) }}
  32. {{- $ca := genCA "zookeeper-quorum-ca" 365 }}
  33. {{- $releaseNamespace := .Release.Namespace }}
  34. {{- $clusterDomain := .Values.clusterDomain }}
  35. {{- $fullname := include "common.names.fullname" . }}
  36. {{- $serviceName := include "common.names.fullname" . }}
  37. {{- $headlessServiceName := printf "%s-headless" (include "common.names.fullname" .) }}
  38. {{- $altNames := list (printf "*.%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $headlessServiceName $releaseNamespace $clusterDomain) (printf "*.%s.%s.svc.%s" $serviceName $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $serviceName $releaseNamespace $clusterDomain) $fullname }}
  39. {{- $cert := genSignedCert $fullname nil $altNames 365 $ca }}
  40. ---
  41. apiVersion: v1
  42. kind: Secret
  43. metadata:
  44. name: {{ $secretName }}
  45. namespace: {{ template "zookeeper.namespace" . }}
  46. labels: {{- include "common.labels.standard" ( dict "customLabels" .Values.commonLabels "context" $ ) | nindent 4 }}
  47. {{- if .Values.commonAnnotations }}
  48. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  49. {{- end }}
  50. type: kubernetes.io/tls
  51. data:
  52. tls.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.crt" "defaultValue" $cert.Cert "context" $) }}
  53. tls.key: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "tls.key" "defaultValue" $cert.Key "context" $) }}
  54. ca.crt: {{ include "common.secrets.lookup" (dict "secret" $secretName "key" "ca.crt" "defaultValue" $ca.Cert "context" $) }}
  55. {{- end }}