diff --git a/invenio/templates/application.yaml b/invenio/templates/application.yaml index 7af3970..099e09b 100644 --- a/invenio/templates/application.yaml +++ b/invenio/templates/application.yaml @@ -38,6 +38,16 @@ spec: labels: app: web spec: + initContainers: + - name: web-init + image: {{ .Values.web.image }} + command: [ + '/bin/bash', + '-c', + 'cp -R {{ .Values.web.assets.location }}/. /tmp/invenio/assets/'] + volumeMounts: + - name: "invenio-assets" + mountPath: "/tmp/invenio/assets/" containers: - name: web image: {{ .Values.web.image }} @@ -84,7 +94,7 @@ spec: - -c - "uwsgi_curl $(hostname):5000 /ping -H 'Host: {{ .Values.host }}'" failureThreshold: 3 - initialDelaySeconds: 15 + initialDelaySeconds: 60 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 1 @@ -102,6 +112,8 @@ spec: volumeMounts: - name: uwsgi-config mountPath: '/opt/invenio/src/uwsgi' + - name: "invenio-assets" + mountPath: "{{ .Values.web.assets.location }}" resources: requests: memory: 200Mi @@ -112,6 +124,10 @@ spec: configMap: defaultMode: 420 name: uwsgi-config + - name: "invenio-assets" + persistentVolumeClaim: + claimName: "invenio-assets-claim" + --- apiVersion: apps.openshift.io/v1 kind: DeploymentConfig diff --git a/invenio/templates/configuration.yaml b/invenio/templates/configuration.yaml index c527349..1056a64 100644 --- a/invenio/templates/configuration.yaml +++ b/invenio/templates/configuration.yaml @@ -74,6 +74,10 @@ data: uwsgi_param X-Forwarded-Proto $http_x_forwarded_proto; uwsgi_ignore_headers Set-Cookie; } + location /static { + alias /opt/invenio/var/instance/static/; + autoindex off; + } } --- apiVersion: v1 diff --git a/invenio/templates/services/nginx.yaml b/invenio/templates/services/nginx.yaml index b4fe94e..5471109 100644 --- a/invenio/templates/services/nginx.yaml +++ b/invenio/templates/services/nginx.yaml @@ -43,8 +43,8 @@ spec: mountPath: /var/cache/nginx - name: var-log-nginx mountPath: /var/log/nginx - - name: static - mountPath: /static + - name: "invenio-assets" + mountPath: "{{ .Values.web.assets.location }}" readinessProbe: httpGet: path: /ping @@ -89,8 +89,9 @@ spec: emptyDir: {} - name: var-log-nginx emptyDir: {} - - name: static - emptyDir: {} + - name: "invenio-assets" + persistentVolumeClaim: + claimName: "invenio-assets-claim" {{ if .Values.logstash.enabled }} --- diff --git a/invenio/templates/volumes.yaml b/invenio/templates/volumes.yaml new file mode 100644 index 0000000..bef018b --- /dev/null +++ b/invenio/templates/volumes.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: "v1" +kind: "PersistentVolumeClaim" +metadata: + name: "invenio-assets-claim" +spec: + accessModes: + - "ReadWriteMany" + resources: + requests: + storage: "{{ .Values.volume.assets.size }}" diff --git a/invenio/values.yaml b/invenio/values.yaml index 7248089..dedf0a8 100644 --- a/invenio/values.yaml +++ b/invenio/values.yaml @@ -4,9 +4,14 @@ haproxy: inside_cluster: true maxconn: 100 +volume: + assets: + size: 10Gi nginx: max_conns: 100 replicas: 2 + assets: + location: /opt/invenio/var/instance/static web: image: your/invenio-image @@ -20,7 +25,8 @@ web: scaler_cpu_utilization: 65 max_web_replicas: 10 min_web_replicas: 2 - + assets: + location: /opt/invenio/var/instance/static worker: enabled: true