From 4f18a5a5ee7bb5773b68c0fc753e6c8846a4df3f Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Tue, 22 Mar 2022 15:44:29 +0100 Subject: [PATCH 1/2] #469 feature: enable application volume to be shared across multiple different deployments --- docs/applications/README.md | 1 + docs/applications/volumes.md | 31 +++++++++++++++++++ .../helm/templates/auto-volumes.yaml | 2 ++ 3 files changed, 34 insertions(+) create mode 100644 docs/applications/volumes.md diff --git a/docs/applications/README.md b/docs/applications/README.md index 28d051dd..b8758632 100644 --- a/docs/applications/README.md +++ b/docs/applications/README.md @@ -95,6 +95,7 @@ The most important configuration entries are the following: - `deployment`: creates a deployment - `auto`: if true, creates the deployment automatically - `resources`: define cpu and memory limits + - `volume`: application persistent volume - `service`: - `auto`: if true, creates the service automatically - `dependencies`: lists of applications/images this application depends from diff --git a/docs/applications/volumes.md b/docs/applications/volumes.md new file mode 100644 index 00000000..3dcee74a --- /dev/null +++ b/docs/applications/volumes.md @@ -0,0 +1,31 @@ +# Application Volume + +Application Volumes are defined at `harness.deployment.volume`. +At the time of writing this documentation CloudHarness supports only one volume per deployment. + +The Application Volume will be mounted in the container at a specific path at **deployment** time. + +A Volume can be mounted by one or more pods (shared Volume). Be careful: only one of the deployments +should create the Volume, the other deployment should only mount it. + +This can be established through setting the `auto` attribute (default false) of the Volume object +auto: true --> auto create the volume and mount +auto: false --> only mount the volume + +Shared volumes are handy when you have e.g. 2 deployments for one app: frontend & backend deployment +in such a case it could be helpfull that the frontend can access files stored by the backend. +E.g. user uploaded media files + +**Example** + +```yaml +harness: + ... + deployment: + ... + volume: + name: myFirstVolume + mountpath: /usr/src/app/myvolume + auto: true + size: 5Gi +``` diff --git a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml index 0748002d..69fcd7fb 100644 --- a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml +++ b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml @@ -1,4 +1,5 @@ {{- define "deploy_utils.pvolume" }} +{{- if not .app.harness.deployment.volume.auto }} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -12,6 +13,7 @@ spec: resources: requests: storage: {{ .app.harness.deployment.volume.size }} +{{- end }} --- {{- end }} {{- range $app := .Values.apps }} From fe40b3a18444fb92d3fb31bee7e0f68d2b5d1271 Mon Sep 17 00:00:00 2001 From: Zoran Sinnema Date: Tue, 22 Mar 2022 15:50:09 +0100 Subject: [PATCH 2/2] #469 fix volumes auto creation, changed if not to if --- .../deployment-configuration/helm/templates/auto-volumes.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml index 69fcd7fb..174d695b 100644 --- a/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml +++ b/tools/cloudharness_utilities/deployment-configuration/helm/templates/auto-volumes.yaml @@ -1,5 +1,5 @@ {{- define "deploy_utils.pvolume" }} -{{- if not .app.harness.deployment.volume.auto }} +{{- if .app.harness.deployment.volume.auto }} apiVersion: v1 kind: PersistentVolumeClaim metadata: