From 0283799700013e13259c9b5d509b75eb4715e26b Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Fri, 11 Dec 2020 20:31:59 +0500 Subject: [PATCH 01/10] Add service account to manage deployments in nextcloud --- test/nextcloud/1.0.0/templates/_helpers.tpl | 7 ++++ .../1.0.0/templates/serviceaccount.yaml | 39 +++++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 test/nextcloud/1.0.0/templates/serviceaccount.yaml diff --git a/test/nextcloud/1.0.0/templates/_helpers.tpl b/test/nextcloud/1.0.0/templates/_helpers.tpl index 3c582e14d7b..431c7293536 100644 --- a/test/nextcloud/1.0.0/templates/_helpers.tpl +++ b/test/nextcloud/1.0.0/templates/_helpers.tpl @@ -113,3 +113,10 @@ Postgres Selector labels app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres app.kubernetes.io/instance: {{ .Release.Name }}-postgres {{- end }} + +{{/* +Nextcloud service account +*/}} +{{- define "nextcloud.serviceAccountName" -}} +{{- printf "%s-service-account" .Release.Name -}} +{{- end -}} diff --git a/test/nextcloud/1.0.0/templates/serviceaccount.yaml b/test/nextcloud/1.0.0/templates/serviceaccount.yaml new file mode 100644 index 00000000000..46a4f18f385 --- /dev/null +++ b/test/nextcloud/1.0.0/templates/serviceaccount.yaml @@ -0,0 +1,39 @@ +apiVersion: v1 +kind: ServiceAccount +metadata: + name: {{ template "nextcloud.serviceAccountName" }} + namespace: {{ .Release.Namespace }} + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: RoleBinding +metadata: + name: {{ .Release.Name }}-service-account-role-binding +subjects: +- kind: ServiceAccount + name: {{ template "nextcloud.serviceAccountName" }} + namespace: {{ .Release.Namespace }} +roleRef: + kind: Role + name: spinupcontainers + apiGroup: rbac.authorization.k8s.io + +--- + +apiVersion: rbac.authorization.k8s.io/v1 +kind: Role +metadata: + name: {{ .Release.Name }}-service-account-role + namespace: {{ .Release.Namespace }} +rules: + - apiGroups: + - "" + - "apps" + resources: + - pods + - deployments + verbs: + - delete + - get + - list From dbde74851d742be187b7cdc0a9b6d2bb85b1fa3c Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Fri, 11 Dec 2020 20:45:40 +0500 Subject: [PATCH 02/10] Add upgrade hook where we nuke nextcloud/postgres deployments --- .../templates/nuke-deployments-hook.yaml | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml diff --git a/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml b/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml new file mode 100644 index 00000000000..34b2ea77bb2 --- /dev/null +++ b/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml @@ -0,0 +1,19 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "pre-upgrade-hook1" + annotations: + "helm.sh/hook": pre-upgrade + "helm.sh/hook-weight": "-1" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "pre-upgrade-hook1" + spec: + restartPolicy: Never + serviceAccountName: {{ template "nextcloud.serviceAccountName" }} + containers: + - name: kubectl + image: "bitnami/kubectl:1.19" + command: ["delete" , "deployment", "{{ template "nextcloud.fullname" . }}", "{{ template "nextcloud.fullname" . }}-postgres"] From 1f15d72cf05ab25ff7b7a7f6f909198e4f823554 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Fri, 11 Dec 2020 21:04:03 +0500 Subject: [PATCH 03/10] Take postgres backup on upgrade --- test/nextcloud/1.0.0/templates/_helpers.tpl | 7 ++++ .../1.0.0/templates/backup-postgres-hook.yaml | 36 +++++++++++++++++++ .../nextcloud/1.0.0/templates/deployment.yaml | 2 +- 3 files changed, 44 insertions(+), 1 deletion(-) create mode 100644 test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml diff --git a/test/nextcloud/1.0.0/templates/_helpers.tpl b/test/nextcloud/1.0.0/templates/_helpers.tpl index 431c7293536..20b46bd16eb 100644 --- a/test/nextcloud/1.0.0/templates/_helpers.tpl +++ b/test/nextcloud/1.0.0/templates/_helpers.tpl @@ -120,3 +120,10 @@ Nextcloud service account {{- define "nextcloud.serviceAccountName" -}} {{- printf "%s-service-account" .Release.Name -}} {{- end -}} + +{{/* +Get Nextloud Postgres Database Name +*/}} +{{- define "postgres.DatabaseName" -}} +{{- print "nextcloud" -}} +{{- end -}} diff --git a/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml b/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml new file mode 100644 index 00000000000..6a566520337 --- /dev/null +++ b/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml @@ -0,0 +1,36 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: "pre-upgrade-hook2" + annotations: + "helm.sh/hook": pre-upgrade + "helm.sh/hook-weight": "1" + "helm.sh/hook-delete-policy": hook-succeeded +spec: + template: + metadata: + name: "pre-upgrade-hook2" + spec: + restartPolicy: Never + serviceAccountName: {{ template "nextcloud.serviceAccountName" }} + containers: + - name: {{ .Chart.Name }}-postgres-backup + image: "postgres:13.1" + imagePullPolicy: {{ .Values.image.pullPolicy }} + env: + - name: POSTGRES_USER + valueFrom: + secretKeyRef: + name: db-details + key: db-user + - name: POSTGRES_PASSWORD + valueFrom: + secretKeyRef: + name: db-details + key: db-password + volumeMounts: + - name: postgres-data + mountPath: /var/lib/postgresql/data + - name: postgres-backup + mountPath: /postgres_backups + command: ['sh', '-c', "/docker-entrypoint.sh; pg_dump -U $POSTGRES_USER -d {{ template "postgres.DatabaseName"}} > /postgres_backups/update_dump;"] diff --git a/test/nextcloud/1.0.0/templates/deployment.yaml b/test/nextcloud/1.0.0/templates/deployment.yaml index e73c7f366de..effca727e56 100644 --- a/test/nextcloud/1.0.0/templates/deployment.yaml +++ b/test/nextcloud/1.0.0/templates/deployment.yaml @@ -49,7 +49,7 @@ spec: - name: POSTGRES_HOST value: {{ template "nextcloud.fullname" . }}-postgres:5432 - name: POSTGRES_DB - value: "nextcloud" + value: {{ template "postgres.DatabaseName" }} - name: POSTGRES_USER valueFrom: secretKeyRef: From 142c8354f8792b681cde4c9e08926f92102ff03a Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sat, 12 Dec 2020 19:01:32 +0500 Subject: [PATCH 04/10] Use a configmap for a script to take backup of postgres --- .../1.0.0/templates/backup-postgres-hook.yaml | 36 +++++++++++++++++-- .../templates/nuke-deployments-hook.yaml | 4 +-- .../1.0.0/templates/serviceaccount.yaml | 10 +++--- 3 files changed, 41 insertions(+), 9 deletions(-) diff --git a/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml b/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml index 6a566520337..5c02335f47e 100644 --- a/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml +++ b/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml @@ -1,3 +1,19 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "postgres-backup-hook-config-map" +data: + entrypoint.sh: |- + #!/bin/sh + cmd="/docker-entrypoint.sh postgres" + eval "${cmd}" & disown; + until pg_isready; do + sleep 5; + done; + pg_dump -U $POSTGRES_USER -d {{ template "postgres.DatabaseName"}} > /postgres_backups/update_dump; + +--- + apiVersion: batch/v1 kind: Job metadata: @@ -12,7 +28,7 @@ spec: name: "pre-upgrade-hook2" spec: restartPolicy: Never - serviceAccountName: {{ template "nextcloud.serviceAccountName" }} + serviceAccountName: "{{ template "nextcloud.serviceAccountName" . }}" containers: - name: {{ .Chart.Name }}-postgres-backup image: "postgres:13.1" @@ -33,4 +49,20 @@ spec: mountPath: /var/lib/postgresql/data - name: postgres-backup mountPath: /postgres_backups - command: ['sh', '-c', "/docker-entrypoint.sh; pg_dump -U $POSTGRES_USER -d {{ template "postgres.DatabaseName"}} > /postgres_backups/update_dump;"] + - name: backup-script-configmap + mountPath: /bin/backup_entrypoint.sh + readOnly: true + subPath: entrypoint.sh + command: + - "/bin/backup_entrypoint.sh" + volumes: + - name: postgres-data + hostPath: + path: {{ template "configuredPostgresHostPath" . }} + - name: postgres-backup + hostPath: + path: {{ template "configuredBackupPostgresHostPath" . }} + - name: backup-script-configmap + configMap: + defaultMode: 0700 + name: "postgres-backup-hook-config-map" diff --git a/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml b/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml index 34b2ea77bb2..dbab1f52e5c 100644 --- a/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml +++ b/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml @@ -12,8 +12,8 @@ spec: name: "pre-upgrade-hook1" spec: restartPolicy: Never - serviceAccountName: {{ template "nextcloud.serviceAccountName" }} + serviceAccountName: "{{ template "nextcloud.serviceAccountName" . }}" containers: - name: kubectl image: "bitnami/kubectl:1.19" - command: ["delete" , "deployment", "{{ template "nextcloud.fullname" . }}", "{{ template "nextcloud.fullname" . }}-postgres"] + command: ["kubectl", "delete" , "deployment", "{{ template "nextcloud.fullname" . }}", "{{ template "nextcloud.fullname" . }}-postgres"] diff --git a/test/nextcloud/1.0.0/templates/serviceaccount.yaml b/test/nextcloud/1.0.0/templates/serviceaccount.yaml index 46a4f18f385..c25bd439fd5 100644 --- a/test/nextcloud/1.0.0/templates/serviceaccount.yaml +++ b/test/nextcloud/1.0.0/templates/serviceaccount.yaml @@ -1,7 +1,7 @@ apiVersion: v1 kind: ServiceAccount metadata: - name: {{ template "nextcloud.serviceAccountName" }} + name: "{{ template "nextcloud.serviceAccountName" . }}" namespace: {{ .Release.Namespace }} --- @@ -9,14 +9,14 @@ metadata: apiVersion: rbac.authorization.k8s.io/v1 kind: RoleBinding metadata: - name: {{ .Release.Name }}-service-account-role-binding + name: "{{ .Release.Name }}-service-account-role-binding" subjects: - kind: ServiceAccount - name: {{ template "nextcloud.serviceAccountName" }} + name: "{{ template "nextcloud.serviceAccountName" . }}" namespace: {{ .Release.Namespace }} roleRef: kind: Role - name: spinupcontainers + name: "{{ .Release.Name }}-service-account-role" apiGroup: rbac.authorization.k8s.io --- @@ -24,7 +24,7 @@ roleRef: apiVersion: rbac.authorization.k8s.io/v1 kind: Role metadata: - name: {{ .Release.Name }}-service-account-role + name: "{{ .Release.Name }}-service-account-role" namespace: {{ .Release.Namespace }} rules: - apiGroups: From 8d8fe11e6b23dfab639068201e75d5b6d412fd06 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sat, 12 Dec 2020 21:04:15 +0500 Subject: [PATCH 05/10] Add helper functions to retrieve new/old chart versions --- test/nextcloud/1.0.0/templates/_backup.tpl | 0 test/nextcloud/1.0.0/templates/_helpers.tpl | 15 -------------- test/nextcloud/1.0.0/templates/_postgres.tpl | 16 +++++++++++++++ test/nextcloud/1.0.0/templates/_upgrade.tpl | 21 ++++++++++++++++++++ 4 files changed, 37 insertions(+), 15 deletions(-) create mode 100644 test/nextcloud/1.0.0/templates/_backup.tpl create mode 100644 test/nextcloud/1.0.0/templates/_postgres.tpl create mode 100644 test/nextcloud/1.0.0/templates/_upgrade.tpl diff --git a/test/nextcloud/1.0.0/templates/_backup.tpl b/test/nextcloud/1.0.0/templates/_backup.tpl new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/nextcloud/1.0.0/templates/_helpers.tpl b/test/nextcloud/1.0.0/templates/_helpers.tpl index 20b46bd16eb..43114be492d 100644 --- a/test/nextcloud/1.0.0/templates/_helpers.tpl +++ b/test/nextcloud/1.0.0/templates/_helpers.tpl @@ -106,24 +106,9 @@ app.kubernetes.io/name: {{ include "nextcloud.name" . }} app.kubernetes.io/instance: {{ .Release.Name }} {{- end }} -{{/* -Postgres Selector labels -*/}} -{{- define "nextcloud.postgres.selectorLabels" -}} -app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres -app.kubernetes.io/instance: {{ .Release.Name }}-postgres -{{- end }} - {{/* Nextcloud service account */}} {{- define "nextcloud.serviceAccountName" -}} {{- printf "%s-service-account" .Release.Name -}} {{- end -}} - -{{/* -Get Nextloud Postgres Database Name -*/}} -{{- define "postgres.DatabaseName" -}} -{{- print "nextcloud" -}} -{{- end -}} diff --git a/test/nextcloud/1.0.0/templates/_postgres.tpl b/test/nextcloud/1.0.0/templates/_postgres.tpl new file mode 100644 index 00000000000..bb0ef0d0d0d --- /dev/null +++ b/test/nextcloud/1.0.0/templates/_postgres.tpl @@ -0,0 +1,16 @@ +{{/* +Get Nextloud Postgres Database Name +*/}} +{{- define "postgres.DatabaseName" -}} +{{- print "nextcloud" -}} +{{- end -}} + +{{/* +Postgres Selector labels +*/}} +{{- define "nextcloud.postgres.selectorLabels" -}} +app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres +app.kubernetes.io/instance: {{ .Release.Name }}-postgres +{{- end }} + + diff --git a/test/nextcloud/1.0.0/templates/_upgrade.tpl b/test/nextcloud/1.0.0/templates/_upgrade.tpl new file mode 100644 index 00000000000..eb0ae1e6603 --- /dev/null +++ b/test/nextcloud/1.0.0/templates/_upgrade.tpl @@ -0,0 +1,21 @@ +{{/* +Retrieve previous chart version from which we are upgrading to a newer chart version +*/}} +{{- define "tn.chart.old_version" -}} +{{- if .Values.ixChartContext.is_upgrade -}} +{{- .Values.ixChartContext.upgradeMetadata.oldChartVersion -}} +{{- else -}} +{{- fail "A chart upgrade is not taking place" -}} +{{- end -}} +{{- end -}} + +{{/* +Retrieve new chart version to which we are upgrading from an old chart version +*/}} +{{- define "tn.chart.new_version" -}} +{{- if .Values.ixChartContext.is_upgrade -}} +{{- .Values.ixChartContext.upgradeMetadata.newChartVersion -}} +{{- else -}} +{{- fail "A chart upgrade is not taking place" -}} +{{- end -}} +{{- end -}} From e52e28fa3c753c046c13e9a87b7854a6cc101f1b Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sun, 13 Dec 2020 23:39:37 +0500 Subject: [PATCH 06/10] Use unique name for backup --- test/nextcloud/1.0.0/templates/_postgres.tpl | 8 +++++++ .../templates/backup-postgres-config.yaml | 15 +++++++++++++ .../1.0.0/templates/backup-postgres-hook.yaml | 21 +++++-------------- .../nextcloud/1.0.0/templates/deployment.yaml | 2 +- .../templates/nuke-deployments-hook.yaml | 3 +++ 5 files changed, 32 insertions(+), 17 deletions(-) create mode 100644 test/nextcloud/1.0.0/templates/backup-postgres-config.yaml diff --git a/test/nextcloud/1.0.0/templates/_postgres.tpl b/test/nextcloud/1.0.0/templates/_postgres.tpl index bb0ef0d0d0d..8889f105714 100644 --- a/test/nextcloud/1.0.0/templates/_postgres.tpl +++ b/test/nextcloud/1.0.0/templates/_postgres.tpl @@ -13,4 +13,12 @@ app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres app.kubernetes.io/instance: {{ .Release.Name }}-postgres {{- end }} +{{/* +Retrieve postgres backup name +This will return a unique name based on revision and chart numbers specified. +*/}} +{{- define "postgres.backupName" -}} +{{- $upgradeDict := .Values.ixChartContext.upgradeMetadata -}} +{{- printf "postgres-backup-from-%s-to-%s-revision-%d" $upgradeDict.oldChartVersion $upgradeDict.newChartVersion (int64 $upgradeDict.preUpgradeRevision) -}} +{{- end }} diff --git a/test/nextcloud/1.0.0/templates/backup-postgres-config.yaml b/test/nextcloud/1.0.0/templates/backup-postgres-config.yaml new file mode 100644 index 00000000000..c9ccf66dbaa --- /dev/null +++ b/test/nextcloud/1.0.0/templates/backup-postgres-config.yaml @@ -0,0 +1,15 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: "postgres-backup-hook-config-map" + annotations: + rollme: {{ randAlphaNum 5 | quote }} +data: + entrypoint.sh: |- + #!/bin/sh + cmd="/docker-entrypoint.sh postgres" + eval "${cmd}" & disown; + until pg_isready; do + sleep 5; + done; + pg_dump -U $POSTGRES_USER -d {{ template "postgres.DatabaseName" . }} > /postgres_backups/$BACKUP_NAME; diff --git a/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml b/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml index 5c02335f47e..5601f8b089c 100644 --- a/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml +++ b/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml @@ -1,19 +1,4 @@ -apiVersion: v1 -kind: ConfigMap -metadata: - name: "postgres-backup-hook-config-map" -data: - entrypoint.sh: |- - #!/bin/sh - cmd="/docker-entrypoint.sh postgres" - eval "${cmd}" & disown; - until pg_isready; do - sleep 5; - done; - pg_dump -U $POSTGRES_USER -d {{ template "postgres.DatabaseName"}} > /postgres_backups/update_dump; - ---- - +{{- if .Values.ixChartContext.isUpgrade -}} apiVersion: batch/v1 kind: Job metadata: @@ -22,6 +7,7 @@ metadata: "helm.sh/hook": pre-upgrade "helm.sh/hook-weight": "1" "helm.sh/hook-delete-policy": hook-succeeded + rollme: {{ randAlphaNum 5 | quote }} spec: template: metadata: @@ -44,6 +30,8 @@ spec: secretKeyRef: name: db-details key: db-password + - name: BACKUP_NAME + value: {{ template "postgres.backupName" . }} volumeMounts: - name: postgres-data mountPath: /var/lib/postgresql/data @@ -66,3 +54,4 @@ spec: configMap: defaultMode: 0700 name: "postgres-backup-hook-config-map" +{{- end -}} diff --git a/test/nextcloud/1.0.0/templates/deployment.yaml b/test/nextcloud/1.0.0/templates/deployment.yaml index effca727e56..643e9826ea6 100644 --- a/test/nextcloud/1.0.0/templates/deployment.yaml +++ b/test/nextcloud/1.0.0/templates/deployment.yaml @@ -49,7 +49,7 @@ spec: - name: POSTGRES_HOST value: {{ template "nextcloud.fullname" . }}-postgres:5432 - name: POSTGRES_DB - value: {{ template "postgres.DatabaseName" }} + value: {{ template "postgres.DatabaseName" . }} - name: POSTGRES_USER valueFrom: secretKeyRef: diff --git a/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml b/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml index dbab1f52e5c..7307db6c1d6 100644 --- a/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml +++ b/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml @@ -1,3 +1,4 @@ +{{- if .Values.ixChartContext.isUpgrade -}} apiVersion: batch/v1 kind: Job metadata: @@ -6,6 +7,7 @@ metadata: "helm.sh/hook": pre-upgrade "helm.sh/hook-weight": "-1" "helm.sh/hook-delete-policy": hook-succeeded + rollme: {{ randAlphaNum 5 | quote }} spec: template: metadata: @@ -17,3 +19,4 @@ spec: - name: kubectl image: "bitnami/kubectl:1.19" command: ["kubectl", "delete" , "deployment", "{{ template "nextcloud.fullname" . }}", "{{ template "nextcloud.fullname" . }}-postgres"] +{{- end -}} From 4b1570fc5838b9361e84c4a50c50a0513269bcf1 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Sun, 13 Dec 2020 23:47:39 +0500 Subject: [PATCH 07/10] Update test values --- test/nextcloud/1.0.0/test_values.yaml | 1 + 1 file changed, 1 insertion(+) diff --git a/test/nextcloud/1.0.0/test_values.yaml b/test/nextcloud/1.0.0/test_values.yaml index d087f4c6f7c..13feb4fc964 100644 --- a/test/nextcloud/1.0.0/test_values.yaml +++ b/test/nextcloud/1.0.0/test_values.yaml @@ -25,3 +25,4 @@ service: nodePort: 31000 emptyDirVolumes: true +ixChartContext: {} From 68044d483502e6d4849e2d48356297b79f17c492 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 14 Dec 2020 16:05:03 +0500 Subject: [PATCH 08/10] Update nextcloud chart version --- test/nextcloud/{1.0.0 => 1.1.0}/.helmignore | 0 test/nextcloud/{1.0.0 => 1.1.0}/Chart.yaml | 2 +- test/nextcloud/{1.0.0 => 1.1.0}/README.md | 0 test/nextcloud/{1.0.0 => 1.1.0}/app-readme.md | 0 test/nextcloud/{1.0.0 => 1.1.0}/questions.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/NOTES.txt | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/_backup.tpl | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/_helpers.tpl | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/_postgres.tpl | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/_upgrade.tpl | 0 .../{1.0.0 => 1.1.0}/templates/backup-postgres-config.yaml | 0 .../{1.0.0 => 1.1.0}/templates/backup-postgres-hook.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/deployment.yaml | 0 .../{1.0.0 => 1.1.0}/templates/nuke-deployments-hook.yaml | 0 .../{1.0.0 => 1.1.0}/templates/postgres-deployment.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/postgres-secret.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/postgres-service.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/secrets.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/service.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/templates/serviceaccount.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/test_values.yaml | 0 test/nextcloud/{1.0.0 => 1.1.0}/values.yaml | 0 22 files changed, 1 insertion(+), 1 deletion(-) rename test/nextcloud/{1.0.0 => 1.1.0}/.helmignore (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/Chart.yaml (96%) rename test/nextcloud/{1.0.0 => 1.1.0}/README.md (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/app-readme.md (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/questions.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/NOTES.txt (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/_backup.tpl (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/_helpers.tpl (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/_postgres.tpl (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/_upgrade.tpl (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/backup-postgres-config.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/backup-postgres-hook.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/deployment.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/nuke-deployments-hook.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/postgres-deployment.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/postgres-secret.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/postgres-service.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/secrets.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/service.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/templates/serviceaccount.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/test_values.yaml (100%) rename test/nextcloud/{1.0.0 => 1.1.0}/values.yaml (100%) diff --git a/test/nextcloud/1.0.0/.helmignore b/test/nextcloud/1.1.0/.helmignore similarity index 100% rename from test/nextcloud/1.0.0/.helmignore rename to test/nextcloud/1.1.0/.helmignore diff --git a/test/nextcloud/1.0.0/Chart.yaml b/test/nextcloud/1.1.0/Chart.yaml similarity index 96% rename from test/nextcloud/1.0.0/Chart.yaml rename to test/nextcloud/1.1.0/Chart.yaml index 81b380228bf..df04f529d5d 100644 --- a/test/nextcloud/1.0.0/Chart.yaml +++ b/test/nextcloud/1.1.0/Chart.yaml @@ -1,6 +1,6 @@ apiVersion: v2 name: nextcloud -version: 1.0.0 +version: 1.1.0 appVersion: 19.0.3 description: A file sharing server that puts the control and security of your own data back into your hands. keywords: diff --git a/test/nextcloud/1.0.0/README.md b/test/nextcloud/1.1.0/README.md similarity index 100% rename from test/nextcloud/1.0.0/README.md rename to test/nextcloud/1.1.0/README.md diff --git a/test/nextcloud/1.0.0/app-readme.md b/test/nextcloud/1.1.0/app-readme.md similarity index 100% rename from test/nextcloud/1.0.0/app-readme.md rename to test/nextcloud/1.1.0/app-readme.md diff --git a/test/nextcloud/1.0.0/questions.yaml b/test/nextcloud/1.1.0/questions.yaml similarity index 100% rename from test/nextcloud/1.0.0/questions.yaml rename to test/nextcloud/1.1.0/questions.yaml diff --git a/test/nextcloud/1.0.0/templates/NOTES.txt b/test/nextcloud/1.1.0/templates/NOTES.txt similarity index 100% rename from test/nextcloud/1.0.0/templates/NOTES.txt rename to test/nextcloud/1.1.0/templates/NOTES.txt diff --git a/test/nextcloud/1.0.0/templates/_backup.tpl b/test/nextcloud/1.1.0/templates/_backup.tpl similarity index 100% rename from test/nextcloud/1.0.0/templates/_backup.tpl rename to test/nextcloud/1.1.0/templates/_backup.tpl diff --git a/test/nextcloud/1.0.0/templates/_helpers.tpl b/test/nextcloud/1.1.0/templates/_helpers.tpl similarity index 100% rename from test/nextcloud/1.0.0/templates/_helpers.tpl rename to test/nextcloud/1.1.0/templates/_helpers.tpl diff --git a/test/nextcloud/1.0.0/templates/_postgres.tpl b/test/nextcloud/1.1.0/templates/_postgres.tpl similarity index 100% rename from test/nextcloud/1.0.0/templates/_postgres.tpl rename to test/nextcloud/1.1.0/templates/_postgres.tpl diff --git a/test/nextcloud/1.0.0/templates/_upgrade.tpl b/test/nextcloud/1.1.0/templates/_upgrade.tpl similarity index 100% rename from test/nextcloud/1.0.0/templates/_upgrade.tpl rename to test/nextcloud/1.1.0/templates/_upgrade.tpl diff --git a/test/nextcloud/1.0.0/templates/backup-postgres-config.yaml b/test/nextcloud/1.1.0/templates/backup-postgres-config.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/backup-postgres-config.yaml rename to test/nextcloud/1.1.0/templates/backup-postgres-config.yaml diff --git a/test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml b/test/nextcloud/1.1.0/templates/backup-postgres-hook.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/backup-postgres-hook.yaml rename to test/nextcloud/1.1.0/templates/backup-postgres-hook.yaml diff --git a/test/nextcloud/1.0.0/templates/deployment.yaml b/test/nextcloud/1.1.0/templates/deployment.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/deployment.yaml rename to test/nextcloud/1.1.0/templates/deployment.yaml diff --git a/test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml b/test/nextcloud/1.1.0/templates/nuke-deployments-hook.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/nuke-deployments-hook.yaml rename to test/nextcloud/1.1.0/templates/nuke-deployments-hook.yaml diff --git a/test/nextcloud/1.0.0/templates/postgres-deployment.yaml b/test/nextcloud/1.1.0/templates/postgres-deployment.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/postgres-deployment.yaml rename to test/nextcloud/1.1.0/templates/postgres-deployment.yaml diff --git a/test/nextcloud/1.0.0/templates/postgres-secret.yaml b/test/nextcloud/1.1.0/templates/postgres-secret.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/postgres-secret.yaml rename to test/nextcloud/1.1.0/templates/postgres-secret.yaml diff --git a/test/nextcloud/1.0.0/templates/postgres-service.yaml b/test/nextcloud/1.1.0/templates/postgres-service.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/postgres-service.yaml rename to test/nextcloud/1.1.0/templates/postgres-service.yaml diff --git a/test/nextcloud/1.0.0/templates/secrets.yaml b/test/nextcloud/1.1.0/templates/secrets.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/secrets.yaml rename to test/nextcloud/1.1.0/templates/secrets.yaml diff --git a/test/nextcloud/1.0.0/templates/service.yaml b/test/nextcloud/1.1.0/templates/service.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/service.yaml rename to test/nextcloud/1.1.0/templates/service.yaml diff --git a/test/nextcloud/1.0.0/templates/serviceaccount.yaml b/test/nextcloud/1.1.0/templates/serviceaccount.yaml similarity index 100% rename from test/nextcloud/1.0.0/templates/serviceaccount.yaml rename to test/nextcloud/1.1.0/templates/serviceaccount.yaml diff --git a/test/nextcloud/1.0.0/test_values.yaml b/test/nextcloud/1.1.0/test_values.yaml similarity index 100% rename from test/nextcloud/1.0.0/test_values.yaml rename to test/nextcloud/1.1.0/test_values.yaml diff --git a/test/nextcloud/1.0.0/values.yaml b/test/nextcloud/1.1.0/values.yaml similarity index 100% rename from test/nextcloud/1.0.0/values.yaml rename to test/nextcloud/1.1.0/values.yaml From b30c99586f70b382b775dbe1f31bce3439f79b89 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 14 Dec 2020 19:32:26 +0500 Subject: [PATCH 09/10] Use pg_isready for determining if postgres is up --- test/nextcloud/1.1.0/templates/deployment.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/nextcloud/1.1.0/templates/deployment.yaml b/test/nextcloud/1.1.0/templates/deployment.yaml index 643e9826ea6..ee58ab34c48 100644 --- a/test/nextcloud/1.1.0/templates/deployment.yaml +++ b/test/nextcloud/1.1.0/templates/deployment.yaml @@ -38,8 +38,8 @@ spec: {{- end }} initContainers: - name: init-postgresdb - image: busybox:latest - command: ['sh', '-c', "until nc -w 5 -vz {{ template "nextcloud.fullname" . }}-postgres 5432; do echo waiting for postgres; sleep 2; done"] + image: "postgres:13.1" + command: ['sh', '-c', "until pg_isready -h {{ template "nextcloud.fullname" . }}-postgres; do echo waiting for postgres; sleep 2; done"] imagePullPolicy: {{ .Values.image.pullPolicy }} containers: - name: {{ .Chart.Name }} From 770b060bbc84947157960e731286274e1cb1d9f2 Mon Sep 17 00:00:00 2001 From: Waqar Ahmed Date: Mon, 14 Dec 2020 19:37:53 +0500 Subject: [PATCH 10/10] Add helper function for postgres name --- test/nextcloud/1.1.0/templates/_postgres.tpl | 4 ++++ test/nextcloud/1.1.0/templates/backup-postgres-hook.yaml | 2 +- test/nextcloud/1.1.0/templates/deployment.yaml | 2 +- test/nextcloud/1.1.0/templates/postgres-deployment.yaml | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/test/nextcloud/1.1.0/templates/_postgres.tpl b/test/nextcloud/1.1.0/templates/_postgres.tpl index 8889f105714..038a680c802 100644 --- a/test/nextcloud/1.1.0/templates/_postgres.tpl +++ b/test/nextcloud/1.1.0/templates/_postgres.tpl @@ -13,6 +13,10 @@ app.kubernetes.io/name: {{ include "nextcloud.name" . }}-postgres app.kubernetes.io/instance: {{ .Release.Name }}-postgres {{- end }} +{{- define "postgres.imageName" -}} +{{- print "postgres:13.1" -}} +{{- end -}} + {{/* Retrieve postgres backup name This will return a unique name based on revision and chart numbers specified. diff --git a/test/nextcloud/1.1.0/templates/backup-postgres-hook.yaml b/test/nextcloud/1.1.0/templates/backup-postgres-hook.yaml index 5601f8b089c..3f6c6dc3662 100644 --- a/test/nextcloud/1.1.0/templates/backup-postgres-hook.yaml +++ b/test/nextcloud/1.1.0/templates/backup-postgres-hook.yaml @@ -17,7 +17,7 @@ spec: serviceAccountName: "{{ template "nextcloud.serviceAccountName" . }}" containers: - name: {{ .Chart.Name }}-postgres-backup - image: "postgres:13.1" + image: {{ template "postgres.imageName" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: POSTGRES_USER diff --git a/test/nextcloud/1.1.0/templates/deployment.yaml b/test/nextcloud/1.1.0/templates/deployment.yaml index ee58ab34c48..a4cfd7c2d7a 100644 --- a/test/nextcloud/1.1.0/templates/deployment.yaml +++ b/test/nextcloud/1.1.0/templates/deployment.yaml @@ -38,7 +38,7 @@ spec: {{- end }} initContainers: - name: init-postgresdb - image: "postgres:13.1" + image: {{ template "postgres.imageName" . }} command: ['sh', '-c', "until pg_isready -h {{ template "nextcloud.fullname" . }}-postgres; do echo waiting for postgres; sleep 2; done"] imagePullPolicy: {{ .Values.image.pullPolicy }} containers: diff --git a/test/nextcloud/1.1.0/templates/postgres-deployment.yaml b/test/nextcloud/1.1.0/templates/postgres-deployment.yaml index da39a2cd76d..47ce9363394 100644 --- a/test/nextcloud/1.1.0/templates/postgres-deployment.yaml +++ b/test/nextcloud/1.1.0/templates/postgres-deployment.yaml @@ -25,7 +25,7 @@ spec: spec: containers: - name: {{ .Chart.Name }}-postgres - image: "postgres:13.1" + image: {{ template "postgres.imageName" . }} imagePullPolicy: {{ .Values.image.pullPolicy }} env: - name: POSTGRES_USER