From 72b39586b61e8266e3c004d23cab19ba2c33ad8b Mon Sep 17 00:00:00 2001 From: Felix Wolf Date: Sat, 4 Apr 2026 18:42:34 +0200 Subject: [PATCH] fix(nextcloud): Enable persistence to survive pod restarts Nextcloud requires a persistent /var/www/html to retain installation state (config.php, version.php, installed apps) across restarts. Without it, every restart triggers the setup wizard. Uses local-path 2Gi PVC with Recreate strategy since the volume is RWO. Co-Authored-By: Claude Opus 4.6 (1M context) --- prototypes/nextcloud/helm/nextcloud.yaml | 14 ++++++------- .../nextcloud/deployment-nextcloud.yaml | 20 +++++-------------- ...stentvolumeclaim-nextcloud-nextcloud.yaml} | 14 +++++++++---- 3 files changed, 21 insertions(+), 27 deletions(-) rename rendered/envs/production/nextcloud/{configmap-nextcloud-hooks.yaml => persistentvolumeclaim-nextcloud-nextcloud.yaml} (62%) diff --git a/prototypes/nextcloud/helm/nextcloud.yaml b/prototypes/nextcloud/helm/nextcloud.yaml index 3e3872f..1b6f7a9 100644 --- a/prototypes/nextcloud/helm/nextcloud.yaml +++ b/prototypes/nextcloud/helm/nextcloud.yaml @@ -57,9 +57,6 @@ nextcloud: opcache.save_comments=1 opcache.revalidate_freq=60 - hooks: - before-starting: touch /var/www/html/config/CAN_INSTALL - extraSidecarContainers: - name: caddy image: caddy:2-alpine @@ -124,10 +121,7 @@ nextcloud: name: nextcloud-caddy-config strategy: - type: RollingUpdate - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 + type: Recreate internalDatabase: enabled: false @@ -165,7 +159,11 @@ cronjob: enabled: true persistence: - enabled: false + enabled: true + size: 2Gi + storageClassName: local-path + annotations: + helm.sh/resource-policy: keep ingress: enabled: true diff --git a/rendered/envs/production/nextcloud/deployment-nextcloud.yaml b/rendered/envs/production/nextcloud/deployment-nextcloud.yaml index 0b1adb0..3ddfc64 100644 --- a/rendered/envs/production/nextcloud/deployment-nextcloud.yaml +++ b/rendered/envs/production/nextcloud/deployment-nextcloud.yaml @@ -20,14 +20,11 @@ spec: app.kubernetes.io/instance: nextcloud app.kubernetes.io/name: nextcloud strategy: - rollingUpdate: - maxSurge: 1 - maxUnavailable: 0 - type: RollingUpdate + type: Recreate template: metadata: annotations: - hooks-hash: 47a89ca9deff73131884ece615e1cabb1f600fec60aa8f20244ae3c5bb58f948 + hooks-hash: 9525c2748a6c7cd0e28ec740623d0b3fa5a75c83b51ccfd136bc89c76737b204 nextcloud-config-hash: ec89ea6d9676ed525984771aab8f4536c9f4f62736b2c9898e883f5d0a7f90f8 php-config-hash: b638f66fd8d65de8364dbad6efc59a6524c7b2e2377b5623cf5e921e4d3d2400 labels: @@ -208,10 +205,6 @@ spec: - mountPath: /usr/local/etc/php/conf.d/uploadLimit.ini name: nextcloud-phpconfig subPath: uploadLimit.ini - - mountPath: /docker-entrypoint-hooks.d/before-starting/helm.sh - name: nextcloud-hooks - readOnly: true - subPath: before-starting.sh - command: - /cron.sh env: @@ -412,18 +405,15 @@ spec: securityContext: fsGroup: 33 volumes: - - emptyDir: {} - name: nextcloud-main + - name: nextcloud-main + persistentVolumeClaim: + claimName: nextcloud-nextcloud - configMap: name: nextcloud-config name: nextcloud-config - configMap: name: nextcloud-phpconfig name: nextcloud-phpconfig - - configMap: - defaultMode: 493 - name: nextcloud-hooks - name: nextcloud-hooks - configMap: name: nextcloud-caddy-config name: caddy-config diff --git a/rendered/envs/production/nextcloud/configmap-nextcloud-hooks.yaml b/rendered/envs/production/nextcloud/persistentvolumeclaim-nextcloud-nextcloud.yaml similarity index 62% rename from rendered/envs/production/nextcloud/configmap-nextcloud-hooks.yaml rename to rendered/envs/production/nextcloud/persistentvolumeclaim-nextcloud-nextcloud.yaml index 611c9af..2518abc 100644 --- a/rendered/envs/production/nextcloud/configmap-nextcloud-hooks.yaml +++ b/rendered/envs/production/nextcloud/persistentvolumeclaim-nextcloud-nextcloud.yaml @@ -1,15 +1,21 @@ apiVersion: v1 -data: - before-starting.sh: touch /var/www/html/config/CAN_INSTALL -kind: ConfigMap +kind: PersistentVolumeClaim metadata: annotations: a8r.io/repository: ssh://git@git.tr1ceracop.de:222/gitea_admin/k8s-and-chill.git + helm.sh/resource-policy: keep labels: + app.kubernetes.io/component: app app.kubernetes.io/instance: nextcloud app.kubernetes.io/managed-by: Helm app.kubernetes.io/name: nextcloud app.kubernetes.io/version: 33.0.0 helm.sh/chart: nextcloud-9.0.4 - name: nextcloud-hooks + name: nextcloud-nextcloud namespace: nextcloud +spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi