From 717c442f62e93c3d5f1020c4021b4930e14127e0 Mon Sep 17 00:00:00 2001 From: Pablo Panero Date: Fri, 20 Mar 2020 10:39:23 +0100 Subject: [PATCH 1/2] web/nginx: shared pvc --- invenio/templates/application.yaml | 18 +++++++++++++++++- invenio/templates/configuration.yaml | 4 ++++ invenio/templates/services/nginx.yaml | 9 +++++---- invenio/templates/volumes.yaml | 11 +++++++++++ invenio/values.yaml | 5 ++++- 5 files changed, 41 insertions(+), 6 deletions(-) create mode 100644 invenio/templates/volumes.yaml diff --git a/invenio/templates/application.yaml b/invenio/templates/application.yaml index 7af3970..c51ddcd 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.statics.location }}/. /tmp/invenio/statics/'] + volumeMounts: + - name: "invenio-statics" + mountPath: "/tmp/invenio/statics/" 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-statics" + mountPath: "{{ .Values.web.statics.location }}" resources: requests: memory: 200Mi @@ -112,6 +124,10 @@ spec: configMap: defaultMode: 420 name: uwsgi-config + - name: "invenio-statics" + persistentVolumeClaim: + claimName: "invenio-statics-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..95a2687 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-statics" + mountPath: "{{ .Values.web.statics.location }}" readinessProbe: httpGet: path: /ping @@ -89,8 +89,9 @@ spec: emptyDir: {} - name: var-log-nginx emptyDir: {} - - name: static - emptyDir: {} + - name: "invenio-statics" + persistentVolumeClaim: + claimName: "invenio-statics-claim" {{ if .Values.logstash.enabled }} --- diff --git a/invenio/templates/volumes.yaml b/invenio/templates/volumes.yaml new file mode 100644 index 0000000..baad8f5 --- /dev/null +++ b/invenio/templates/volumes.yaml @@ -0,0 +1,11 @@ +--- +apiVersion: "v1" +kind: "PersistentVolumeClaim" +metadata: + name: "invenio-statics-claim" +spec: + accessModes: + - "ReadWriteMany" + resources: + requests: + storage: "10Gi" diff --git a/invenio/values.yaml b/invenio/values.yaml index 7248089..ed54452 100644 --- a/invenio/values.yaml +++ b/invenio/values.yaml @@ -7,6 +7,8 @@ haproxy: nginx: max_conns: 100 replicas: 2 + statics: + location: /opt/invenio/var/instance/static web: image: your/invenio-image @@ -20,7 +22,8 @@ web: scaler_cpu_utilization: 65 max_web_replicas: 10 min_web_replicas: 2 - + statics: + location: /opt/invenio/var/instance/static worker: enabled: true From 6b2d57e3922ad0b731c0c477e40f264b94f0c6c4 Mon Sep 17 00:00:00 2001 From: Pablo Panero Date: Mon, 23 Mar 2020 13:41:00 +0100 Subject: [PATCH 2/2] shared volume: configure size and rename statics to assets Co-authored-by: Georgios Lignos --- invenio/templates/application.yaml | 14 +++++++------- invenio/templates/services/nginx.yaml | 8 ++++---- invenio/templates/volumes.yaml | 4 ++-- invenio/values.yaml | 7 +++++-- 4 files changed, 18 insertions(+), 15 deletions(-) diff --git a/invenio/templates/application.yaml b/invenio/templates/application.yaml index c51ddcd..099e09b 100644 --- a/invenio/templates/application.yaml +++ b/invenio/templates/application.yaml @@ -44,10 +44,10 @@ spec: command: [ '/bin/bash', '-c', - 'cp -R {{ .Values.web.statics.location }}/. /tmp/invenio/statics/'] + 'cp -R {{ .Values.web.assets.location }}/. /tmp/invenio/assets/'] volumeMounts: - - name: "invenio-statics" - mountPath: "/tmp/invenio/statics/" + - name: "invenio-assets" + mountPath: "/tmp/invenio/assets/" containers: - name: web image: {{ .Values.web.image }} @@ -112,8 +112,8 @@ spec: volumeMounts: - name: uwsgi-config mountPath: '/opt/invenio/src/uwsgi' - - name: "invenio-statics" - mountPath: "{{ .Values.web.statics.location }}" + - name: "invenio-assets" + mountPath: "{{ .Values.web.assets.location }}" resources: requests: memory: 200Mi @@ -124,9 +124,9 @@ spec: configMap: defaultMode: 420 name: uwsgi-config - - name: "invenio-statics" + - name: "invenio-assets" persistentVolumeClaim: - claimName: "invenio-statics-claim" + claimName: "invenio-assets-claim" --- apiVersion: apps.openshift.io/v1 diff --git a/invenio/templates/services/nginx.yaml b/invenio/templates/services/nginx.yaml index 95a2687..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: "invenio-statics" - mountPath: "{{ .Values.web.statics.location }}" + - name: "invenio-assets" + mountPath: "{{ .Values.web.assets.location }}" readinessProbe: httpGet: path: /ping @@ -89,9 +89,9 @@ spec: emptyDir: {} - name: var-log-nginx emptyDir: {} - - name: "invenio-statics" + - name: "invenio-assets" persistentVolumeClaim: - claimName: "invenio-statics-claim" + claimName: "invenio-assets-claim" {{ if .Values.logstash.enabled }} --- diff --git a/invenio/templates/volumes.yaml b/invenio/templates/volumes.yaml index baad8f5..bef018b 100644 --- a/invenio/templates/volumes.yaml +++ b/invenio/templates/volumes.yaml @@ -2,10 +2,10 @@ apiVersion: "v1" kind: "PersistentVolumeClaim" metadata: - name: "invenio-statics-claim" + name: "invenio-assets-claim" spec: accessModes: - "ReadWriteMany" resources: requests: - storage: "10Gi" + storage: "{{ .Values.volume.assets.size }}" diff --git a/invenio/values.yaml b/invenio/values.yaml index ed54452..dedf0a8 100644 --- a/invenio/values.yaml +++ b/invenio/values.yaml @@ -4,10 +4,13 @@ haproxy: inside_cluster: true maxconn: 100 +volume: + assets: + size: 10Gi nginx: max_conns: 100 replicas: 2 - statics: + assets: location: /opt/invenio/var/instance/static web: @@ -22,7 +25,7 @@ web: scaler_cpu_utilization: 65 max_web_replicas: 10 min_web_replicas: 2 - statics: + assets: location: /opt/invenio/var/instance/static worker: