From 79ebec888610a16c2fdffeb79f1f2232719679c6 Mon Sep 17 00:00:00 2001 From: "K.Filippopolitis" <56073635+KFilippopolitis@users.noreply.github.com> Date: Fri, 23 Aug 2024 17:18:08 +0300 Subject: [PATCH] Added a volume for Portalbackend logs. (#168) Co-authored-by: Kostas Filippopolitis Co-authored-by: Julien D --- .../portalbackend-integration-tests.yml | 8 ++- dev/docker-compose.yml | 2 - dev/start.sh | 4 +- dev/tests/test_federation_info.py | 2 +- kubernetes/templates/portalbackend.yaml | 52 +++++++++++++++++++ kubernetes/values.yaml | 6 ++- 6 files changed, 66 insertions(+), 8 deletions(-) diff --git a/.github/workflows/portalbackend-integration-tests.yml b/.github/workflows/portalbackend-integration-tests.yml index ad568338..b82a05a0 100644 --- a/.github/workflows/portalbackend-integration-tests.yml +++ b/.github/workflows/portalbackend-integration-tests.yml @@ -18,6 +18,12 @@ jobs: with: python-version: 3.8 + - name: Install Docker Compose + run: | + sudo curl -L "https://github.com/docker/compose/releases/download/$(curl -s https://api.github.com/repos/docker/compose/releases/latest | grep tag_name | cut -d '"' -f 4)/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose + sudo chmod +x /usr/local/bin/docker-compose + docker-compose --version + - name: Deploy portalbackend and exareme2 working-directory: ./dev/ run: bash start.sh @@ -32,5 +38,3 @@ jobs: - name: Run the federation info tests working-directory: ./dev/ run: pytest tests/test_federation_info.py - - diff --git a/dev/docker-compose.yml b/dev/docker-compose.yml index 24743a43..c12ed4b3 100644 --- a/dev/docker-compose.yml +++ b/dev/docker-compose.yml @@ -1,5 +1,3 @@ -version: '3.7' - services: exareme2_local_rabbitmq: image: madgik/exareme2_rabbitmq:${EXAREME2} diff --git a/dev/start.sh b/dev/start.sh index 8bd5eef7..2e6bb42a 100755 --- a/dev/start.sh +++ b/dev/start.sh @@ -10,8 +10,8 @@ echo -n "Waiting for containers to start ..." sleep 10 echo -n "Loading data into exareme2 db ..." -docker exec dev_exareme2_global_mipdb_1 mipdb init -docker exec dev_exareme2_local_mipdb_1 /bin/bash -c "mipdb init && mipdb load-folder /opt/data" +docker exec dev-exareme2_global_mipdb-1 mipdb init +docker exec dev-exareme2_local_mipdb-1 /bin/bash -c "mipdb init && mipdb load-folder /opt/data" sleep 10 diff --git a/dev/tests/test_federation_info.py b/dev/tests/test_federation_info.py index 25aab4e2..16bfeefd 100644 --- a/dev/tests/test_federation_info.py +++ b/dev/tests/test_federation_info.py @@ -6,7 +6,7 @@ def test_federation_info(): - cmd = f"docker logs dev_portalbackend_1 | python3 ../federation_info.py show-portal-backend-audit-entries" + cmd = f"docker logs dev-portalbackend-1 | python3 ../federation_info.py show-portal-backend-audit-entries" res = subprocess.run( cmd, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE ) diff --git a/kubernetes/templates/portalbackend.yaml b/kubernetes/templates/portalbackend.yaml index 6dc17737..8f916220 100644 --- a/kubernetes/templates/portalbackend.yaml +++ b/kubernetes/templates/portalbackend.yaml @@ -91,6 +91,53 @@ spec: requests: storage: {{ .Values.portalbackend.storage.storage0.data_size }} +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: portalbackend-logs-vol0 + namespace: {{ .Values.namespace }} + labels: + storage: portalbackend-logs-storage0 +spec: + capacity: + storage: {{ .Values.portalbackend.logs.storage0.data_size }} + volumeMode: Filesystem + accessModes: + - ReadWriteOnce + persistentVolumeReclaimPolicy: Retain + storageClassName: k8s-local-storage + hostPath: + path: {{ .Values.portalbackend.logs.storage0.data_path }} + type: DirectoryOrCreate + nodeAffinity: + required: + nodeSelectorTerms: + - matchExpressions: + - key: master + operator: In + values: + - "true" + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: portalbackend-logs-claim0 + namespace: {{ .Values.namespace }} + labels: + storage: portalbackend-logs-storage0 +spec: + selector: + matchLabels: + storage: portalbackend-logs-storage0 + storageClassName: k8s-local-storage + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ .Values.portalbackend.logs.storage0.data_size }} + --- apiVersion: apps/v1 kind: Deployment @@ -121,6 +168,9 @@ spec: - name: portalbackend-claim0 persistentVolumeClaim: claimName: portalbackend-claim0 + - name: portalbackend-logs-claim0 + persistentVolumeClaim: + claimName: portalbackend-logs-claim0 containers: - name: portalbackend-db image: {{ .Values.portalbackend_db.image.name }}:{{ .Values.portalbackend_db.image.version }} @@ -147,6 +197,8 @@ spec: volumeMounts: - name: portalbackend-claim0 mountPath: /opt/portal/api + - name: portalbackend-logs-claim0 + mountPath: /var/log/portalbackend env: - name: LOG_LEVEL valueFrom: diff --git a/kubernetes/values.yaml b/kubernetes/values.yaml index 1c12d560..b2661353 100644 --- a/kubernetes/values.yaml +++ b/kubernetes/values.yaml @@ -41,11 +41,15 @@ portalbackend: ALGORITHM_UPDATE_INTERVAL: 60 # seconds image: name: hbpmip/portal-backend - version: 8.0.4 + version: 8.0.6 storage: storage0: data_path: /opt/mip-deployment/config data_size: 100Mi + logs: + storage0: + data_path: /opt/mip-deployment/logs + data_size: 1Gi gateway_db: image: