mirror of
https://github.com/truenas/charts.git
synced 2026-04-13 17:52:13 +08:00
Update nextcloud chart migrating it to newer storage format
This commit is contained in:
23
test/nextcloud/1.1.0/migrations/migrate
Executable file
23
test/nextcloud/1.1.0/migrations/migrate
Executable file
@@ -0,0 +1,23 @@
|
||||
#!/usr/bin/python3
|
||||
import json
|
||||
import sys
|
||||
|
||||
|
||||
def migrate(values):
|
||||
values.update({
|
||||
'appVolumeMounts': {
|
||||
'nextcloud-data': {
|
||||
'hostPathEnabled': values['nextcloudDataHostPathEnabled'],
|
||||
**({'hostPath': values['nextcloudHostPath']} if values.get('nextcloudHostPath') else {})
|
||||
},
|
||||
},
|
||||
'updateStrategy': values.get('nextcloud').get('strategy', 'Recreate'),
|
||||
})
|
||||
return values
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
if len(sys.argv) != 2:
|
||||
exit(1)
|
||||
|
||||
print(json.dumps(migrate(json.loads(sys.argv[1]))))
|
||||
@@ -9,6 +9,8 @@ groups:
|
||||
description: "Configure nextcloud container parameters"
|
||||
- name: "Postgresql Configuration"
|
||||
description: "Configure Postgresql for nextcloud"
|
||||
- name: "Scaling/Upgrade Policy"
|
||||
description: "Configure how pods are replaced when configuration is upgraded"
|
||||
|
||||
portals:
|
||||
web_portal:
|
||||
@@ -94,16 +96,20 @@ questions:
|
||||
type: path
|
||||
default: "/var/www/html/data"
|
||||
required: true
|
||||
- variable: strategy
|
||||
label: "Nextcloud update strategy"
|
||||
schema:
|
||||
type: string
|
||||
default: "Recreate"
|
||||
enum:
|
||||
- value: "RollingUpdate"
|
||||
description: "Create new pods and then kill old ones"
|
||||
- value: "Recreate"
|
||||
description: "Kill existing pods before creating new ones"
|
||||
|
||||
# Update strategy
|
||||
- variable: updateStrategy
|
||||
description: "Upgrade Policy"
|
||||
label: "Update Strategy"
|
||||
group: "Scaling/Upgrade Policy"
|
||||
schema:
|
||||
type: string
|
||||
default: "Recreate"
|
||||
enum:
|
||||
- value: "RollingUpdate"
|
||||
description: "Create new pods and then kill old ones"
|
||||
- value: "Recreate"
|
||||
description: "Kill existing pods before creating new ones"
|
||||
|
||||
- variable: service
|
||||
description: "Nextcloud Service Configuration"
|
||||
@@ -122,80 +128,89 @@ questions:
|
||||
default: 9001
|
||||
required: true
|
||||
|
||||
- variable: nextcloudDataHostPathEnabled
|
||||
label: "Configure Host Path for Nextcloud data"
|
||||
group: "Storage"
|
||||
schema:
|
||||
type: boolean
|
||||
default: false
|
||||
show_subquestions_if: true
|
||||
subquestions:
|
||||
- variable: nextcloudHostPath
|
||||
label: "Specify HostPath for Nextcloud data"
|
||||
schema:
|
||||
type: hostpath
|
||||
|
||||
- variable: nextcloudDataVolume
|
||||
label: "Nextcloud Data Volume Defaults"
|
||||
- variable: appVolumeMounts
|
||||
label: "Nextcloud Storage"
|
||||
group: "Storage"
|
||||
schema:
|
||||
type: dict
|
||||
$ref:
|
||||
- "normalize/ixVolume"
|
||||
show_if: [["nextcloudDataHostPathEnabled", "=", false]]
|
||||
attrs:
|
||||
- variable: mountPath
|
||||
label: "Nextcloud Data Mount Path"
|
||||
description: "Path where the volume will be mounted inside the pod"
|
||||
- variable: nextcloud-data
|
||||
label: "Nextcloud Data Volume"
|
||||
schema:
|
||||
type: path
|
||||
editable: false
|
||||
default: "/var/www"
|
||||
- variable: datasetName
|
||||
label: "Nextcloud Dataset Name"
|
||||
schema:
|
||||
type: string
|
||||
default: "ix-nextcloud_data"
|
||||
editable: false
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: datasetName
|
||||
label: "Nextcloud Data Volume Name"
|
||||
schema:
|
||||
type: string
|
||||
$ref:
|
||||
- "normalize/ixVolume"
|
||||
show_if: [["hostPathEnabled", "=", false]]
|
||||
default: "ix-nextcloud_data"
|
||||
editable: false
|
||||
- variable: mountPath
|
||||
label: "Nextcloud Data Mount Path"
|
||||
description: "Path where the volume will be mounted inside the pod"
|
||||
schema:
|
||||
type: path
|
||||
editable: false
|
||||
default: "/var/www"
|
||||
- variable: hostPathEnabled
|
||||
label: "Enable Host Path for Nextcloud Data Volume"
|
||||
schema:
|
||||
type: boolean
|
||||
default: false
|
||||
show_subquestions_if: true
|
||||
subquestions:
|
||||
- variable: hostPath
|
||||
label: "Host Path for Nextcloud Data Volume"
|
||||
schema:
|
||||
type: hostpath
|
||||
required: true
|
||||
|
||||
- variable: postgresBackupVolume
|
||||
label: "Postgres Backup Volume Defaults"
|
||||
- variable: postgresAppVolumeMounts
|
||||
label: "Postgres Storage"
|
||||
group: "Storage"
|
||||
schema:
|
||||
type: dict
|
||||
$ref:
|
||||
- "normalize/ixVolume"
|
||||
attrs:
|
||||
- variable: mountPath
|
||||
label: "Postgres Backup Mount Path"
|
||||
- variable: postgres-data
|
||||
label: "Postgres Data Volume"
|
||||
schema:
|
||||
type: path
|
||||
editable: false
|
||||
default: "/postgres_backups"
|
||||
- variable: datasetName
|
||||
label: "Postgres Backup Dataset Name"
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: datasetName
|
||||
label: "Postgres Data Volume Name"
|
||||
schema:
|
||||
type: string
|
||||
$ref:
|
||||
- "normalize/ixVolume"
|
||||
default: "ix-postgres_data"
|
||||
editable: false
|
||||
- variable: mountPath
|
||||
label: "Postgresql Data Mount Path"
|
||||
description: "Path where the volume will be mounted inside the pod"
|
||||
schema:
|
||||
type: path
|
||||
editable: false
|
||||
default: "/var/lib/postgresql/data"
|
||||
- variable: postgres-backup
|
||||
label: "Postgres Backup Volume"
|
||||
schema:
|
||||
type: string
|
||||
default: "ix-postgres_backups"
|
||||
editable: false
|
||||
|
||||
- variable: postgresDataVolume
|
||||
label: "Postgresql Data Volume Defaults"
|
||||
group: "Storage"
|
||||
schema:
|
||||
type: dict
|
||||
$ref:
|
||||
- "normalize/ixVolume"
|
||||
attrs:
|
||||
- variable: mountPath
|
||||
label: "Postgres Mount Path"
|
||||
schema:
|
||||
type: path
|
||||
editable: false
|
||||
default: "/var/lib/postgresql/data"
|
||||
- variable: datasetName
|
||||
label: "Postgres Dataset Name"
|
||||
schema:
|
||||
type: string
|
||||
default: "ix-postgres_data"
|
||||
editable: false
|
||||
type: dict
|
||||
attrs:
|
||||
- variable: datasetName
|
||||
label: "Postgres Backup Volume Name"
|
||||
schema:
|
||||
type: string
|
||||
$ref:
|
||||
- "normalize/ixVolume"
|
||||
default: "ix-postgres_backups"
|
||||
editable: false
|
||||
- variable: mountPath
|
||||
label: "Postgresql Backup Mount Path"
|
||||
description: "Path where the volume will be mounted inside the pod"
|
||||
schema:
|
||||
type: path
|
||||
editable: false
|
||||
default: "/postgres_backups"
|
||||
|
||||
@@ -1,114 +0,0 @@
|
||||
{{/* vim: set filetype=mustache: */}}
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "nextcloud.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "nextcloud.fullname" -}}
|
||||
{{- if .Values.fullnameOverride -}}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride -}}
|
||||
{{- if contains $name .Release.Name -}}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- else -}}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "nextcloud.mariadb.fullname" -}}
|
||||
{{- printf "%s-%s" .Release.Name "mariadb" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified redis app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
*/}}
|
||||
{{- define "nextcloud.redis.fullname" -}}
|
||||
{{- printf "%s-%s" .Release.Name "redis" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "nextcloud.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Retrieve host path from ix volumes based on dataset name
|
||||
*/}}
|
||||
{{- define "retrieveHostPathFromiXVolume" -}}
|
||||
{{- range $index, $hostPathConfiguration := $.ixVolumes }}
|
||||
{{- $dsName := base $hostPathConfiguration.hostPath -}}
|
||||
{{- if eq $.datasetName $dsName -}}
|
||||
{{- $hostPathConfiguration.hostPath -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Retrieve host path defined in volume
|
||||
*/}}
|
||||
{{- define "configuredHostPath" -}}
|
||||
{{- if .Values.emptyDirVolumes -}}
|
||||
{{- printf "" -}}
|
||||
{{- else if .Values.nextcloudDataHostPathEnabled -}}
|
||||
{{- required "Please specify a host path for nextcloud" .Values.nextcloudHostPath -}}
|
||||
{{- else -}}
|
||||
{{- $volDict := dict "datasetName" $.Values.nextcloudDataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
|
||||
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Retrieve backup postgresql host path defined in volume
|
||||
*/}}
|
||||
{{- define "configuredBackupPostgresHostPath" -}}
|
||||
{{- if .Values.emptyDirVolumes -}}
|
||||
{{- printf "" -}}
|
||||
{{- else -}}
|
||||
{{- $volDict := dict "datasetName" $.Values.postgresBackupVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
|
||||
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Retrieve postgresql data host path defined in volume
|
||||
*/}}
|
||||
{{- define "configuredPostgresHostPath" -}}
|
||||
{{- if .Values.emptyDirVolumes -}}
|
||||
{{- printf "" -}}
|
||||
{{- else -}}
|
||||
{{- $volDict := dict "datasetName" $.Values.postgresDataVolume.datasetName "ixVolumes" $.Values.ixVolumes -}}
|
||||
{{- include "retrieveHostPathFromiXVolume" $volDict -}}
|
||||
{{- end -}}
|
||||
{{- end -}}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "nextcloud.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "nextcloud.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Nextcloud service account
|
||||
*/}}
|
||||
{{- define "nextcloud.serviceAccountName" -}}
|
||||
{{- printf "%s-service-account" .Release.Name -}}
|
||||
{{- end -}}
|
||||
@@ -36,8 +36,14 @@ Retrieve postgres credentials for environment variables configuration
|
||||
Retrieve postgres volume configuration
|
||||
*/}}
|
||||
{{- define "postgres.volumeConfiguration" -}}
|
||||
{{ $vols := list }}
|
||||
{{ $vols = mustAppend $vols (dict "name" "postgres-data" "emptyDirVolumes" .Values.emptyDirVolumes "hostPathEnabled" false "pathField" nil "datasetName" (.Values.postgresDataVolume | default dict).datasetName ) }}
|
||||
{{ $vols = mustAppend $vols (dict "name" "postgres-backup" "emptyDirVolumes" .Values.emptyDirVolumes "hostPathEnabled" false "pathField" nil "datasetName" (.Values.postgresBackupVolume | default dict).datasetName ) }}
|
||||
{{ include "common.storage.volumesConfiguration" (dict "ixVolumes" .Values.ixVolumes "volumes" $vols) }}
|
||||
{{ include "common.storage.configureAppVolumes" (dict "appVolumeMounts" .Values.postgresAppVolumeMounts "emptyDirVolumes" .Values.emptyDirVolumes "ixVolumes" .Values.ixVolumes) | nindent 0 }}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
{{/*
|
||||
Retrieve postgres volume mounts configuration
|
||||
*/}}
|
||||
{{- define "postgres.volumeMountsConfiguration" -}}
|
||||
{{ include "common.storage.configureAppVolumeMountsInContainer" (dict "appVolumeMounts" .Values.postgresAppVolumeMounts ) | nindent 0 }}
|
||||
{{- end -}}
|
||||
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
{{/*
|
||||
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 -}}
|
||||
@@ -1,6 +1,6 @@
|
||||
{{- if .Values.ixChartContext.isUpgrade -}}
|
||||
{{ $values := . }}
|
||||
{{ $_ := set $values "nameSuffix" "postgres" }}
|
||||
{{ $values := (. | mustDeepCopy) }}
|
||||
{{ $_ := set $values "common" (dict "nameSuffix" "postgres") }}
|
||||
apiVersion: batch/v1
|
||||
kind: Job
|
||||
metadata:
|
||||
@@ -24,11 +24,7 @@ spec:
|
||||
env: {{ include "postgres.envVariableConfiguration" $values | nindent 10 }}
|
||||
- name: BACKUP_NAME
|
||||
value: {{ template "postgres.backupName" . }}
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: postgres-backup
|
||||
mountPath: /postgres_backups
|
||||
volumeMounts: {{ include "postgres.volumeMountsConfiguration" $values | nindent 10 }}
|
||||
- name: backup-script-configmap
|
||||
mountPath: /bin/backup_entrypoint.sh
|
||||
readOnly: true
|
||||
|
||||
@@ -1,21 +1,8 @@
|
||||
{{ $postgres_values := (. | mustDeepCopy) }}
|
||||
{{ $_ := set $postgres_values "common" (dict "nameSuffix" "postgres") }}
|
||||
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" . }}
|
||||
labels: {{ include "common.labels" . | nindent 4 }}
|
||||
annotations: {{ include "common.annotations" . | nindent 4 }}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: {{ .Values.nextcloud.strategy }}
|
||||
selector:
|
||||
matchLabels: {{ include "common.labels.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels: {{ include "common.labels.selectorLabels" . | nindent 8 }}
|
||||
annotations: {{ include "common.annotations" . | nindent 8 }}
|
||||
{{ include "common.deployment.common_config" . | nindent 0 }}
|
||||
spec: {{ include "common.deployment.common_spec" . | nindent 2 }}
|
||||
template: {{ include "common.deployment.pod.metadata" . | nindent 4 }}
|
||||
spec:
|
||||
initContainers:
|
||||
- name: init-postgresdb
|
||||
@@ -61,10 +48,7 @@ spec:
|
||||
- name: nextcloud-data
|
||||
mountPath: /var/www/html/themes
|
||||
subPath: "themes"
|
||||
volumes:
|
||||
{{ $vols := list }}
|
||||
{{ $vols = mustAppend $vols (dict "name" "nextcloud-data" "emptyDirVolumes" .Values.emptyDirVolumes "hostPathEnabled" .Values.nextcloudDataHostPathEnabled "pathField" .Values.nextcloudHostPath "datasetName" (.Values.nextcloudDataVolume | default dict).datasetName ) }}
|
||||
{{ include "common.storage.volumesConfiguration" (dict "ixVolumes" .Values.ixVolumes "volumes" $vols) | nindent 8 }}
|
||||
{{ include "common.storage.allAppVolumes" .Values | nindent 6 }}
|
||||
# Will mount configuration files as www-data (id: 33) for nextcloud
|
||||
securityContext:
|
||||
fsGroup: 33
|
||||
|
||||
@@ -1,31 +1,15 @@
|
||||
{{ $values := (. | mustDeepCopy) }}
|
||||
{{ $_ := set $values "common" (dict "nameSuffix" "postgres") }}
|
||||
apiVersion: {{ include "common.capabilities.deployment.apiVersion" . }}
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ template "common.names.fullname" $values }}
|
||||
labels: {{ include "common.labels.selectorLabels" $values | nindent 4 }}
|
||||
spec:
|
||||
replicas: 1
|
||||
strategy:
|
||||
type: {{ .Values.nextcloud.strategy }}
|
||||
selector:
|
||||
matchLabels: {{- include "common.labels.selectorLabels" $values | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
labels: {{- include "common.labels.selectorLabels" $values | nindent 8 }}
|
||||
annotations: {{- include "common.annotations" $values | nindent 8 }}
|
||||
{{ include "common.deployment.common_config" $values | nindent 0 }}
|
||||
spec: {{ include "common.deployment.common_spec" $values | nindent 2 }}
|
||||
template: {{ include "common.deployment.pod.metadata" $values | nindent 4 }}
|
||||
spec:
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}-postgres
|
||||
image: {{ template "postgres.imageName" . }}
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
env: {{ include "postgres.envVariableConfiguration" $values | nindent 10 }}
|
||||
volumeMounts:
|
||||
- name: postgres-data
|
||||
mountPath: /var/lib/postgresql/data
|
||||
- name: postgres-backup
|
||||
mountPath: /postgres_backups
|
||||
volumeMounts: {{ include "postgres.volumeMountsConfiguration" $values | nindent 10 }}
|
||||
ports:
|
||||
- name: postgres-tcp
|
||||
containerPort: 5432
|
||||
|
||||
Reference in New Issue
Block a user