From bdea2a6f8fe6e0bb89d3dd32e9841fc9e2dd67c5 Mon Sep 17 00:00:00 2001 From: Stavros Kois <47820033+stavros-k@users.noreply.github.com> Date: Tue, 29 Aug 2023 15:53:58 +0300 Subject: [PATCH] NAS-122722 / 24.04 / nextcloud - display db details on NOTES.txt (#1484) * display db details on NOTES.txt * typo --- library/ix-dev/charts/nextcloud/Chart.yaml | 2 +- .../charts/nextcloud/templates/NOTES.txt | 17 +++++++++++-- .../nextcloud/templates/deployment.yaml | 1 + .../nextcloud/templates/postgres-secret.yaml | 24 +++++++++++-------- 4 files changed, 31 insertions(+), 13 deletions(-) diff --git a/library/ix-dev/charts/nextcloud/Chart.yaml b/library/ix-dev/charts/nextcloud/Chart.yaml index 3ce399ff91..5a7e9ddcbe 100644 --- a/library/ix-dev/charts/nextcloud/Chart.yaml +++ b/library/ix-dev/charts/nextcloud/Chart.yaml @@ -4,7 +4,7 @@ description: A file sharing server that puts the control and security of your ow annotations: title: Nextcloud type: application -version: 1.6.40 +version: 1.6.41 apiVersion: v2 appVersion: 27.0.2 kubeVersion: '>=1.16.0-0' diff --git a/library/ix-dev/charts/nextcloud/templates/NOTES.txt b/library/ix-dev/charts/nextcloud/templates/NOTES.txt index 9b2f7cd2d1..6ad5448619 100644 --- a/library/ix-dev/charts/nextcloud/templates/NOTES.txt +++ b/library/ix-dev/charts/nextcloud/templates/NOTES.txt @@ -1,3 +1,16 @@ -1. Get the nextcloud URL by running: +## Database +You can connect to the database using the pgAdmin App from the catalog - echo http://{{ .Values.nextcloud.host }}:{{ .Values.service.nodePort }}/ +
+ Database Details + + - Database: `nextcloud` + - Username: `{{ .Values.nextcloudDbUser | b64dec }}` + - Password: `{{ .Values.nextcloudDbPass | b64dec }}` + - Host: `{{ .Values.nextcloudDbHost }}.{{ .Release.Namespace }}.svc.cluster.local` + - Port: `5432` + +
+{{- $_ := unset .Values "nextcloudDbUser" }} +{{- $_ := unset .Values "nextcloudDbPass" }} +{{- $_ := unset .Values "nextcloudDbHost" }} diff --git a/library/ix-dev/charts/nextcloud/templates/deployment.yaml b/library/ix-dev/charts/nextcloud/templates/deployment.yaml index 7e970fc30d..41451a1ab3 100644 --- a/library/ix-dev/charts/nextcloud/templates/deployment.yaml +++ b/library/ix-dev/charts/nextcloud/templates/deployment.yaml @@ -74,6 +74,7 @@ spec: {{ include "common.deployment.common_spec" . | nindent 2 }} env: {{ include "postgres.envVariableConfiguration" $postgres_values | nindent 10 }} {{ $secretName := (include "common.names.fullname" .) }} {{ $envList := (default list .Values.environmentVariables) }} + {{- $_ := set .Values "nextcloudDbHost" (include "common.names.fullname" $postgres_values) -}} {{/* Temprary store it on values to display it on NOTES */}} {{ $envList = mustAppend $envList (dict "name" "POSTGRES_HOST" "value" (printf "%s:5432" (include "common.names.fullname" $postgres_values))) }} {{ $envList = mustAppend $envList (dict "name" "POSTGRES_DB" "value" (include "postgres.DatabaseName" .)) }} {{ $envList = mustAppend $envList (dict "name" "NEXTCLOUD_DATA_DIR" "value" .Values.nextcloud.datadir) }} diff --git a/library/ix-dev/charts/nextcloud/templates/postgres-secret.yaml b/library/ix-dev/charts/nextcloud/templates/postgres-secret.yaml index 2ebc8b9b17..6c265ba0e6 100644 --- a/library/ix-dev/charts/nextcloud/templates/postgres-secret.yaml +++ b/library/ix-dev/charts/nextcloud/templates/postgres-secret.yaml @@ -10,13 +10,17 @@ data: characters. So to keep that user for existing installations we retrieve it from the existing secret. */}} - {{ with (lookup "v1" "Secret" .Release.Namespace $secretName)}} - db-user: {{ index .data "db-user" }} - {{ else }} - db-user: {{ (include "postgres.DatabaseName" .Values ) | b64enc }} - {{ end }} - {{ with (lookup "v1" "Secret" .Release.Namespace $secretName) }} - db-password: {{ index .data "db-password" }} - {{ else }} - db-password: {{ randAlphaNum 15 | b64enc }} - {{ end }} + {{/* Init values */}} + {{- $dbUser := ((include "postgres.DatabaseName" .Values) | b64enc) -}} + {{- $dbPass := (randAlphaNum 15 | b64enc) -}} + {{- with (lookup "v1" "Secret" .Release.Namespace $secretName) -}} + {{/* If there is a previous secret, use that */}} + {{- $dbUser = (index .data "db-user") -}} + {{- $dbPass = (index .data "db-password") -}} + {{- end }} + db-user: {{ $dbUser }} + db-password: {{ $dbPass }} + +{{/* Temprary store them on values to display it on NOTES */}} +{{ $_ := set .Values "nextcloudDbPass" $dbPass }} +{{ $_ := set .Values "nextcloudDbUser" $dbUser }}