Add upgrade and backup
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Wed, 27 Nov 2019 17:05:06 +0100
changeset 131 f711839dc2e2
parent 130 8e7356b5098e
child 132 60f15e7bf5f7
Add upgrade and backup
deploy/deployment.yaml
--- a/deploy/deployment.yaml	Thu Nov 21 14:53:25 2019 +0100
+++ b/deploy/deployment.yaml	Wed Nov 27 17:05:06 2019 +0100
@@ -55,6 +55,24 @@
         - name: bfss
           persistentVolumeClaim:
             claimName: fresh
+        - name: backup
+          persistentVolumeClaim:
+            claimName: backup
+      initContainers:
+        - name: upgrade
+          image: r.intra.logilab.fr/intranet/fresh
+          imagePullPolicy: Always
+          command: ["cubicweb-ctl", "upgrade", "--backup-db=y", "--force", "--verbosity=0", "fresh"]
+          envFrom:
+            - secretRef:
+                name: fresh-env
+          resources:
+            requests:
+              cpu: 50m
+              memory: 500Mi
+          volumeMounts:
+            - name: backup
+              mountPath: /etc/cubicweb.d/fresh/backup
       containers:
         - name: fresh
           image: r.intra.logilab.fr/intranet/fresh
@@ -69,6 +87,8 @@
               mountPath: /secret
             - name: bfss
               mountPath: /etc/cubicweb.d/fresh/bfss
+            - name: backup
+              mountPath: /etc/cubicweb.d/fresh/backup
           command: [
             "/bin/sh", "-c",
             "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/fresh/cwclientlibrc && exec /entrypoint.sh start"
@@ -160,3 +180,38 @@
   ports:
     - protocol: TCP
       port: 8000
+---
+apiVersion: batch/v1beta1
+kind: CronJob
+metadata:
+  name: fresh-backup
+spec:
+  schedule: "0 6 * * *"
+  concurrencyPolicy: Forbid
+  jobTemplate:
+    spec:
+      template:
+        metadata:
+          labels:
+            app: fresh
+        spec:
+          restartPolicy: Never
+          volumes:
+            - name: backup
+              persistentVolumeClaim:
+                claimName: backup
+          containers:
+            - name: fresh
+              image: r.intra.logilab.fr/intranet/fresh
+              imagePullPolicy: Always
+              command: ["cubicweb-ctl", "db-dump", "fresh"]
+              envFrom:
+                - secretRef:
+                    name: fresh-env
+              volumeMounts:
+                - name: backup
+                  mountPath: /etc/cubicweb.d/fresh/backup
+              resources:
+                requests:
+                  cpu: 50m
+                  memory: 500Mi