This commit is contained in:
j 2025-08-23 03:16:01 +00:00
parent c0082f0c7c
commit 635e70a876

View file

@ -149,17 +149,13 @@ spec:
--- ---
# This is a Kubernetes CronJob that executes the Nextcloud background tasks.
# It is designed to run the 'cron.php' script every 5 minutes.
apiVersion: batch/v1 apiVersion: batch/v1
kind: CronJob kind: CronJob
metadata: metadata:
name: nextcloud-cron name: nextcloud-cron
namespace: home-server namespace: home-server
spec: spec:
# The schedule for the cron job, in standard cron format.
# This will run the job every 5 minutes.
schedule: "*/5 * * * *" schedule: "*/5 * * * *"
successfulJobsHistoryLimit: 3 successfulJobsHistoryLimit: 3
failedJobsHistoryLimit: 1 failedJobsHistoryLimit: 1
@ -167,22 +163,15 @@ spec:
spec: spec:
template: template:
spec: spec:
# This security context ensures the job runs with the correct user and group
# for the Nextcloud container, which is often www-data (UID 33).
securityContext: securityContext:
runAsUser: 33 runAsUser: 33
runAsGroup: 33 runAsGroup: 33
containers: containers:
- name: nextcloud-cron - name: nextcloud-cron
# Use the same Nextcloud image as the main deployment to ensure consistency.
image: nextcloud:30 image: nextcloud:30
imagePullPolicy: IfNotPresent imagePullPolicy: IfNotPresent
# The command to execute. 'php -f /var/www/html/cron.php' is the official
# Nextcloud command for running background tasks.
command: ["php", "-f", "/var/www/html/cron.php"] command: ["php", "-f", "/var/www/html/cron.php"]
env: env:
# The environment variables are passed to the cron job container so it
# can connect to the same database as the main Nextcloud pod.
- name: MYSQL_PASSWORD - name: MYSQL_PASSWORD
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
@ -195,14 +184,15 @@ spec:
- name: MYSQL_HOST - name: MYSQL_HOST
value: mariadb.database value: mariadb.database
volumeMounts: volumeMounts:
# Mount the persistent volume claim to access the Nextcloud installation
# and data directories.
- name: nextcloud-data - name: nextcloud-data
mountPath: /var/www/html mountPath: /var/www/html
- name: nextcloud-data-j
mountPath: /var/www/html/data/34034c4d6cb6a6f4b6dfa8e8cb482e16171e867faf9d03714c0bed9ab2e87a9e/files
volumes: volumes:
- name: nextcloud-data - name: nextcloud-data
persistentVolumeClaim: persistentVolumeClaim:
claimName: nextcloud-pvc claimName: nextcloud-pvc
# Set the restart policy to 'OnFailure' to allow the job to complete and - name: nextcloud-data-j
# not remain in a running state. persistentVolumeClaim:
claimName: nextcloud-data-j-pvc
restartPolicy: OnFailure restartPolicy: OnFailure