diff --git a/bookstack-helm/templates/backupscript.yaml b/bookstack-helm/templates/backup_script.yaml similarity index 92% rename from bookstack-helm/templates/backupscript.yaml rename to bookstack-helm/templates/backup_script.yaml index 7bb361d..ec42264 100644 --- a/bookstack-helm/templates/backupscript.yaml +++ b/bookstack-helm/templates/backup_script.yaml @@ -25,16 +25,18 @@ data: backup_name="wiki_backup_files_$(date +%s).tar.gz" tar -chzvf $backup_name /app/www/public/uploads/ /app/www/storage/uploads/ /app/www/public/img/ echo "push to s3" - apk add aws-cli aws s3 cp ./$backup_name "$BACKUP_S3_URL" echo "uploaded" rm $backup_name echo "done" - backup.files.hook.sh: | - echo "setting hook" + backup.entrypoint.sh: | + echo "Startup" + apk add aws-cli echo "sh /backup.files.sh" >> /etc/periodic/daily/backup - crond - echo "done" + chmod +x /etc/periodic/daily/backup + echo "Starting crond" + crond -f + echo "Error: Cron exited" restore.db.sh: | echo "Checking if restore is needed" echo "Restore file is: $RESTORE_S3_URL" diff --git a/bookstack-helm/templates/bookstack.yaml b/bookstack-helm/templates/bookstack.yaml index c7e8e97..641a394 100644 --- a/bookstack-helm/templates/bookstack.yaml +++ b/bookstack-helm/templates/bookstack.yaml @@ -33,7 +33,7 @@ spec: imagePullPolicy: {{ .Values.image.pullPolicy }} ports: - name: http - containerPort: {{ .Values.service.port }} + containerPort: {{ .Values.bookstack.service.port }} protocol: TCP env: - name: TZ @@ -140,10 +140,6 @@ spec: mountPath: /backup.files.sh subPath: backup.files.sh readOnly: true - - name: backup-hook - mountPath: /backup.files.hook.sh - subPath: backup.files.hook.sh - readOnly: true {{- if .Values.bookstack.enableLivenessProbe }} livenessProbe: httpGet: @@ -162,10 +158,45 @@ spec: {{- end }} resources: {{- toYaml .Values.bookstack.resources | nindent 12 }} - lifecycle: - postStart: - exec: - command: ["/bin/sh", "/backup.files.hook.sh"] + initContainers: + - name: backup-cron + image: alpine:latest + restartPolicy: Always + command: ['sh', '/backup.entrypoint.sh'] + env: + - name: APP_URL + valueFrom: + configMapKeyRef: + name: wikiconfig + key: APP_URL + - name: AWS_ACCESS_KEY_ID + valueFrom: + secretKeyRef: + name: wiki-secrets + key: access-key-id + - name: AWS_SECRET_ACCESS_KEY + valueFrom: + secretKeyRef: + name: wiki-secrets + key: secret-access-key + - name: BACKUP_S3_URL + valueFrom: + secretKeyRef: + name: wiki-secrets + key: backup-s3-url + volumeMounts: + - name: config-vol + mountPath: /config + - name: image-uploads-vol + mountPath: /app/www/public/img + - name: backup-script + mountPath: /backup.files.sh + subPath: backup.files.sh + readOnly: true + - name: backup-entrypoint + mountPath: /backup.entrypoint.sh + subPath: backup.entrypoint.sh + readOnly: true volumes: - name: config-vol persistentVolumeClaim: @@ -179,12 +210,12 @@ spec: items: - key: backup.files.sh path: backup.files.sh - - name: backup-hook + - name: backup-entrypoint configMap: name: backup-script items: - - key: backup.files.hook.sh - path: backup.files.hook.sh + - key: backup.entrypoint.sh + path: backup.entrypoint.sh {{- with .Values.nodeSelector }} nodeSelector: {{- toYaml . | nindent 8 }} diff --git a/bookstack-helm/templates/bookstack_service.yaml b/bookstack-helm/templates/bookstack_service.yaml index 05df610..d9d4004 100644 --- a/bookstack-helm/templates/bookstack_service.yaml +++ b/bookstack-helm/templates/bookstack_service.yaml @@ -6,12 +6,10 @@ metadata: labels: {{- include "bookstack-helm.labels" . | nindent 4 }} spec: - type: NodePort ports: - port: {{ .Values.bookstack.port }} targetPort: {{ .Values.bookstack.port }} protocol: TCP name: http - nodePort: 30875 selector: app: bookstack diff --git a/bookstack-helm/values.yaml b/bookstack-helm/values.yaml index 73531b1..9eb978a 100644 --- a/bookstack-helm/values.yaml +++ b/bookstack-helm/values.yaml @@ -45,6 +45,8 @@ bookstack: enableLivenessProbe: true livenessProbeInitialDelaySeconds: 20 livenessProbePeriodSeconds: 15 + service: + port: 8080 image: repository: lscr.io/linuxserver/bookstack @@ -84,9 +86,6 @@ securityContext: {} # runAsNonRoot: true # runAsUser: 1000 -service: - port: 8080 - # autoscaling: # enabled: false # minReplicas: 1