From 3edb5908498274abda87ef50f12ecf4743c3474c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Robert=20Sch=C3=A4fer?= Date: Wed, 24 Apr 2019 22:48:39 +0200 Subject: [PATCH] Dedicate extra chapter to volumes --- SUMMARY.md | 1 + deployment/human-connection/README.md | 8 ++++ .../human-connection/deployment-backend.yaml | 12 ------ .../human-connection/deployment-neo4j.yaml | 12 ------ deployment/volumes/README.md | 42 +++++++++++++++++++ deployment/volumes/neo4j-data.yaml | 12 ++++++ deployment/volumes/uploads.yaml | 12 ++++++ 7 files changed, 75 insertions(+), 24 deletions(-) create mode 100644 deployment/volumes/README.md create mode 100644 deployment/volumes/neo4j-data.yaml create mode 100644 deployment/volumes/uploads.yaml diff --git a/SUMMARY.md b/SUMMARY.md index 24470f8fa..7c1e41d13 100644 --- a/SUMMARY.md +++ b/SUMMARY.md @@ -26,6 +26,7 @@ * [Kubernetes Dashboard](deployment/digital-ocean/dashboard/README.md) * [HTTPS](deployment/digital-ocean/https/README.md) * [Human Connection](deployment/human-connection/README.md) + * [Volumes](deployment/volumes/README.md) * [Neo4J DB Backup](deployment/backup.md) * [Legacy Migration](deployment/legacy-migration/README.md) * [Feature Specification](cypress/features.md) diff --git a/deployment/human-connection/README.md b/deployment/human-connection/README.md index 7df30e345..f281a4617 100644 --- a/deployment/human-connection/README.md +++ b/deployment/human-connection/README.md @@ -37,6 +37,14 @@ If you have a [kubernets dashboard](../digital-ocean/dashboard/README.md) deployed you should switch to namespace `human-connection` in order to monitor the state of your deployments. +## Create persistent volumes + +While the deployments and services can easily be restored, simply by deleting +and applying the kubernetes configurations again, certain data is not that +easily recovered. Therefore we separated persistent volumes from deployments +and services. There is a [dedicated section](../volumes/README.md). Create those +persistent volumes once before you apply the configuration. + ## Apply the configuration ```text diff --git a/deployment/human-connection/deployment-backend.yaml b/deployment/human-connection/deployment-backend.yaml index 29992ef7e..a873b7bb2 100644 --- a/deployment/human-connection/deployment-backend.yaml +++ b/deployment/human-connection/deployment-backend.yaml @@ -43,15 +43,3 @@ restartPolicy: Always terminationGracePeriodSeconds: 30 status: {} ---- - kind: PersistentVolumeClaim - apiVersion: v1 - metadata: - name: uploads-claim - namespace: human-connection - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 2Gi diff --git a/deployment/human-connection/deployment-neo4j.yaml b/deployment/human-connection/deployment-neo4j.yaml index 5b89b3656..4a715da76 100644 --- a/deployment/human-connection/deployment-neo4j.yaml +++ b/deployment/human-connection/deployment-neo4j.yaml @@ -57,15 +57,3 @@ claimName: neo4j-data-claim restartPolicy: Always terminationGracePeriodSeconds: 30 ---- - kind: PersistentVolumeClaim - apiVersion: v1 - metadata: - name: neo4j-data-claim - namespace: human-connection - spec: - accessModes: - - ReadWriteOnce - resources: - requests: - storage: 1Gi diff --git a/deployment/volumes/README.md b/deployment/volumes/README.md new file mode 100644 index 000000000..b838794d5 --- /dev/null +++ b/deployment/volumes/README.md @@ -0,0 +1,42 @@ +# Persistent Volumes + +At the moment, the application needs two persistent volumes: + +* The `/data/` folder where `neo4j` stores its database and +* the folder `/nitro-backend/public/uploads` where the backend stores uploads. + +As a matter of precaution, the persistent volume claims that setup these volumes +live in a separate folder. You don't want to accidently loose all your data in +your database by running `kubectl delete -f human-connection/`, do you? + +## Create Persistent Volume Claims + +Run the following: +```sh +# in folder deployments/ +$ kubectl apply -f volumes +persistentvolumeclaim/neo4j-data-claim created +persistentvolumeclaim/uploads-claim created +``` + +## Change Reclaim Policy + +We recommend to change the `ReclaimPolicy`, so if you delete the persistent +volume claims, the associated volumes will be released, not deleted: + +```sh +$ kubectl --namespace=human-connection get pv + +NAME CAPACITY ACCESS MODES RECLAIM POLICY STATUS CLAIM STORAGECLASS REASON AGE +pvc-bd02a715-66d0-11e9-be52-ba9c337f4551 1Gi RWO Delete Bound human-connection/neo4j-data-claim do-block-storage 4m24s +pvc-bd208086-66d0-11e9-be52-ba9c337f4551 2Gi RWO Delete Bound human-connection/uploads-claim do-block-storage 4m12s +``` + +Get the volume id from above, then change `ReclaimPolicy` with: +```sh +kubectl patch pv -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}' + +# in the above example +kubectl patch pv pvc-bd02a715-66d0-11e9-be52-ba9c337f4551 -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}' +kubectl patch pv pvc-bd208086-66d0-11e9-be52-ba9c337f4551 -p '{"spec":{"persistentVolumeReclaimPolicy":"Retain"}}' +``` diff --git a/deployment/volumes/neo4j-data.yaml b/deployment/volumes/neo4j-data.yaml new file mode 100644 index 000000000..f077be933 --- /dev/null +++ b/deployment/volumes/neo4j-data.yaml @@ -0,0 +1,12 @@ +--- + kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: neo4j-data-claim + namespace: human-connection + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 1Gi diff --git a/deployment/volumes/uploads.yaml b/deployment/volumes/uploads.yaml new file mode 100644 index 000000000..11a8027e9 --- /dev/null +++ b/deployment/volumes/uploads.yaml @@ -0,0 +1,12 @@ +--- + kind: PersistentVolumeClaim + apiVersion: v1 + metadata: + name: uploads-claim + namespace: human-connection + spec: + accessModes: + - ReadWriteOnce + resources: + requests: + storage: 2Gi