[deploy] add support for bfss for uploads
authorPhilippe Pepiot <philippe.pepiot@logilab.fr>
Thu, 18 Jul 2019 11:43:25 +0200
changeset 111 c85712f80d85
parent 110 e4e6a0b0719a
child 112 d1355979f82d
[deploy] add support for bfss for uploads We use bfss to store upload of (mostly) pdf files. Add a persistent volume claim and mount it in /var/lib/cubicweb/instances/fresh/bfss To make this work with previous instance we have to rename the instance to "fresh".
Dockerfile
README.rst
deploy/deployment.yaml
deploy/pvc.yaml
--- a/Dockerfile	Thu Jul 18 11:40:02 2019 +0200
+++ b/Dockerfile	Thu Jul 18 11:43:25 2019 +0200
@@ -1,6 +1,8 @@
+ARG CW_INSTANCE_NAME=fresh
 FROM hub.extranet.logilab.fr/cubicweb/cubicweb:3.26-onbuild
 USER root
 RUN pip install -r /src/docker/requirements.txt
 RUN cp /src/docker/pyramid.ini.j2 /pyramid.ini.j2
+RUN install -d -o cubicweb -g cubicweb /etc/cubicweb.d/fresh/bfss /var/lib/cubicweb/instances/fresh
 USER cubicweb
 ENV WITH_TRUSTEDAUTH=false
--- a/README.rst	Thu Jul 18 11:40:02 2019 +0200
+++ b/README.rst	Thu Jul 18 11:43:25 2019 +0200
@@ -11,10 +11,10 @@
 
 Some useful commands::
 
-* ``cubicweb-ctl db-create -a instance`` will create and initialize the
+* ``cubicweb-ctl db-create -a fresh`` will create and initialize the
   database
 
-* ``cubicweb-ctl pyramid -D -l info instance`` will start the instance on
+* ``cubicweb-ctl pyramid -D -l info fresh`` will start the instance on
   http://localhost:8080
 
 Deploying on kubernetes
@@ -28,7 +28,7 @@
       --env CW_DB_PASSWORD=pass \
       --env CW_DB_NAME=fresh \
       --image=hub.extranet.logilab.fr/logilab/fresh --command -- \
-      cubicweb-ctl db-create --automatic --create-db=n instance
+      cubicweb-ctl db-create --automatic --create-db=n fresh
    kubectl delete deployment fresh-dbcreate
 
 
@@ -51,6 +51,11 @@
    kubectl create secret generic fresh-cwclientlibrc --from-file=./cwclientlibrc
 
 
+Create a persistent volume for bfss data::
+
+   kubectl apply -f deploy/pvc.yaml
+
+
 Then deploy fresh with::
 
-   kubectl apply -f deployment.yaml
+   kubectl apply -f deploy/deployment.yaml
--- a/deploy/deployment.yaml	Thu Jul 18 11:40:02 2019 +0200
+++ b/deploy/deployment.yaml	Thu Jul 18 11:43:25 2019 +0200
@@ -7,7 +7,7 @@
   default.conf: |
     server {
       listen 8000 default_server;
-      root /etc/cubicweb.d/instance/data;
+      root /etc/cubicweb.d/fresh/data;
       rewrite ^/fresh/(.*) /$1 last;
 
       location / {
@@ -23,7 +23,7 @@
       }
 
       location /data {
-        alias /etc/cubicweb.d/instance/data;
+        alias /etc/cubicweb.d/fresh/data;
         expires 30d;
       }
     }
@@ -53,6 +53,9 @@
         - name: cwclientlibrc
           secret:
             secretName: fresh-cwclientlibrc
+        - name: bfss
+          persistentVolumeClaim:
+            claimName: fresh
       containers:
         - name: fresh
           image: hub.extranet.logilab.fr/logilab/fresh
@@ -62,12 +65,14 @@
                 name: fresh-env
           volumeMounts:
             - name: static
-              mountPath: /etc/cubicweb.d/instance/data
+              mountPath: /etc/cubicweb.d/fresh/data
             - name: cwclientlibrc
               mountPath: /secret
+            - name: bfss
+              mountPath: /etc/cubicweb.d/fresh/bfss
           command: [
             "/bin/sh", "-c",
-            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/instance/cwclientlibrc && exec /entrypoint.sh start"
+            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/fresh/cwclientlibrc && exec /entrypoint.sh start"
           ]
           resources:
             requests:
@@ -83,7 +88,7 @@
               mountPath: /etc/nginx/conf.d/default.conf
               subPath: default.conf
             - name: static
-              mountPath: /etc/cubicweb.d/instance/data
+              mountPath: /etc/cubicweb.d/fresh/data
           resources:
             requests:
               cpu: 100m
@@ -122,6 +127,9 @@
         - name: cwclientlibrc
           secret:
             secretName: fresh-cwclientlibrc
+        - name: bfss
+          persistentVolumeClaim:
+            claimName: fresh
       containers:
         - name: fresh
           image: hub.extranet.logilab.fr/logilab/fresh
@@ -132,9 +140,11 @@
           volumeMounts:
             - name: cwclientlibrc
               mountPath: /secret
+            - name: bfss
+              mountPath: /etc/cubicweb.d/fresh/bfss
           command: [
             "/bin/sh", "-c",
-            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/instance/cwclientlibrc && exec cubicweb-ctl sheduler instance"
+            "install -m 400 /secret/cwclientlibrc /etc/cubicweb.d/fresh/cwclientlibrc && exec cubicweb-ctl scheduler fresh"
           ]
           resources:
             requests:
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/deploy/pvc.yaml	Thu Jul 18 11:43:25 2019 +0200
@@ -0,0 +1,13 @@
+apiVersion: v1
+kind: PersistentVolumeClaim
+metadata:
+  labels:
+    app: fresh
+  name: fresh
+  namespace: intranet
+spec:
+  accessModes:
+    - ReadWriteMany
+  resources:
+    requests:
+      storage: 10Gi