tls-secrets.yaml 1.8 KB

12345678910111213141516171819202122232425262728293031
  1. {{- if (include "kafka.createTlsSecret" .) }}
  2. {{- $replicaCount := int .Values.replicaCount }}
  3. {{- $releaseNamespace := .Release.Namespace }}
  4. {{- $clusterDomain := .Values.clusterDomain }}
  5. {{- $fullname := include "common.names.fullname" . }}
  6. {{- $ca := genCA "kafka-ca" 365 }}
  7. {{- range $i := until $replicaCount }}
  8. {{- $secretName := printf "%s-%d-tls" (include "common.names.fullname" $) $i }}
  9. {{- $replicaHost := printf "%s-%d.%s-headless" $fullname $i $fullname }}
  10. {{- $altNames := list (printf "%s.%s.svc.%s" $replicaHost $releaseNamespace $clusterDomain) (printf "%s.%s.svc.%s" $fullname $releaseNamespace $clusterDomain) (printf "%s.%s" $replicaHost $releaseNamespace) (printf "%s.%s" $fullname $releaseNamespace) $replicaHost $fullname }}
  11. {{- $cert := genSignedCert $replicaHost nil $altNames 365 $ca }}
  12. apiVersion: v1
  13. kind: Secret
  14. metadata:
  15. name: {{ printf "%s-%d-tls" (include "common.names.fullname" $) $i }}
  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. ---
  30. {{- end }}
  31. {{- end }}