secrets.yaml 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. {{- $host := include "mysql.primary.fullname" . }}
  2. {{- $port := print .Values.primary.service.ports.mysql }}
  3. {{- $rootPassword := include "common.secrets.passwords.manage" (dict "secret" (include "mysql.secretName" .) "key" "mysql-root-password" "length" 10 "providedValues" (list "auth.rootPassword") "context" $) | trimAll "\"" | b64dec }}
  4. {{- $password := include "common.secrets.passwords.manage" (dict "secret" (include "mysql.secretName" .) "key" "mysql-password" "length" 10 "providedValues" (list "auth.password") "context" $) | trimAll "\"" | b64dec }}
  5. {{- if eq (include "mysql.createSecret" .) "true" }}
  6. apiVersion: v1
  7. kind: Secret
  8. metadata:
  9. name: {{ include "common.names.fullname" . }}
  10. namespace: {{ include "common.names.namespace" . | quote }}
  11. labels: {{- include "common.labels.standard" . | nindent 4 }}
  12. {{- if .Values.commonLabels }}
  13. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  14. {{- end }}
  15. {{- if .Values.commonAnnotations }}
  16. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  17. {{- end }}
  18. type: Opaque
  19. data:
  20. mysql-root-password: {{ print $rootPassword | b64enc | quote }}
  21. mysql-password: {{ print $password | b64enc | quote }}
  22. {{- if eq .Values.architecture "replication" }}
  23. mysql-replication-password: {{ include "common.secrets.passwords.manage" (dict "secret" (include "common.names.fullname" .) "key" "mysql-replication-password" "length" 10 "providedValues" (list "auth.replicationPassword") "context" $) }}
  24. {{- end }}
  25. {{- end }}
  26. {{- if .Values.serviceBindings.enabled }}
  27. ---
  28. apiVersion: v1
  29. kind: Secret
  30. metadata:
  31. name: {{ include "common.names.fullname" . }}-svcbind-root
  32. namespace: {{ .Release.Namespace | quote }}
  33. labels: {{- include "common.labels.standard" . | nindent 4 }}
  34. {{- if .Values.commonLabels }}
  35. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  36. {{- end }}
  37. {{- if .Values.commonAnnotations }}
  38. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  39. {{- end }}
  40. type: servicebinding.io/mysql
  41. data:
  42. provider: {{ print "bitnami" | b64enc | quote }}
  43. type: {{ print "mysql" | b64enc | quote }}
  44. host: {{ print $host | b64enc | quote }}
  45. port: {{ print $port | b64enc | quote }}
  46. user: {{ print "root" | b64enc | quote }}
  47. password: {{ print $rootPassword | b64enc | quote }}
  48. uri: {{ printf "mysql://root:%s@%s:%s" $rootPassword $host $port | b64enc | quote }}
  49. {{- if .Values.auth.username }}
  50. {{- $database := .Values.auth.database }}
  51. ---
  52. apiVersion: v1
  53. kind: Secret
  54. metadata:
  55. name: {{ include "common.names.fullname" . }}-svcbind-custom-user
  56. namespace: {{ .Release.Namespace | quote }}
  57. labels: {{- include "common.labels.standard" . | nindent 4 }}
  58. {{- if .Values.commonLabels }}
  59. {{- include "common.tplvalues.render" ( dict "value" .Values.commonLabels "context" $ ) | nindent 4 }}
  60. {{- end }}
  61. {{- if .Values.commonAnnotations }}
  62. annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  63. {{- end }}
  64. type: servicebinding.io/mysql
  65. data:
  66. provider: {{ print "bitnami" | b64enc | quote }}
  67. type: {{ print "mysql" | b64enc | quote }}
  68. host: {{ print $host | b64enc | quote }}
  69. port: {{ print $port | b64enc | quote }}
  70. user: {{ print .Values.auth.username | b64enc | quote }}
  71. {{- if $database }}
  72. database: {{ print $database | b64enc | quote }}
  73. {{- end }}
  74. password: {{ print $password | b64enc | quote }}
  75. uri: {{ printf "mysql://%s:%s@%s:%s/%s" .Values.auth.username $password $host $port $database | b64enc | quote }}
  76. {{- end }}
  77. {{- end }}