postgres-secret.yaml 954 B

1234567891011121314151617181920212223242526
  1. {{- $secretName := "db-details" }}
  2. apiVersion: v1
  3. kind: Secret
  4. metadata:
  5. name: {{ $secretName }}
  6. data:
  7. {{/*
  8. Lookup for the user shouldn't be needed in normal circumstances
  9. But there was a typo before that resulted to a db-user with weird
  10. characters. So to keep that user for existing installations we retrieve
  11. it from the existing secret.
  12. */}}
  13. {{/* Init values */}}
  14. {{- $dbUser := ((include "postgres.DatabaseName" .Values) | b64enc) -}}
  15. {{- $dbPass := (randAlphaNum 15 | b64enc) -}}
  16. {{- with (lookup "v1" "Secret" .Release.Namespace $secretName) -}}
  17. {{/* If there is a previous secret, use that */}}
  18. {{- $dbUser = (index .data "db-user") -}}
  19. {{- $dbPass = (index .data "db-password") -}}
  20. {{- end }}
  21. db-user: {{ $dbUser }}
  22. db-password: {{ $dbPass }}
  23. {{/* Temprary store them on values to display it on NOTES */}}
  24. {{ $_ := set .Values "nextcloudDbPass" $dbPass }}
  25. {{ $_ := set .Values "nextcloudDbUser" $dbUser }}