From 98fb18c0636ee416ec84392a976201d6edf1d7b3 Mon Sep 17 00:00:00 2001
From: David Hoese <david.hoese@ssec.wisc.edu>
Date: Wed, 22 Jul 2020 11:47:46 -0500
Subject: [PATCH] Update GRB processing to hopefully reuse PVC if it exists

---
 .gitlab-ci.yml  |  9 +++++++--
 admin/README.md | 24 ++++++++++++++++++++++++
 2 files changed, 31 insertions(+), 2 deletions(-)

diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 0402050..97b019a 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -167,11 +167,16 @@ deploy_g16_grb:
     - kubeconfig=$(basename $kubekorner_k3s_config)
     - echo "Deploying version $docker_tag to cluster namespace $ns"
     - pvc=$(kubectl --kubeconfig $kubeconfig get pvc --namespace $ns cspp-geo-grb -o jsonpath="{.metadata.name}" || echo "");
-    - echo $pvc
+    - if [ "$pvc" != "" ]; then
+        EXTRA_ARGS="--set persistence.existingClaim=$pvc";
+      else
+        EXTRA_ARGS="--set persistence.enabled=true";
+    fi
+    - echo $EXTRA_ARGS
     # copy extra values files to the local directory (where helm has access via docker mount)
     - cp ../../production/values-grb-g16.yaml .
     # namespace names are the same as domain names
-    - helm upgrade -v 2 --install --kubeconfig $kubeconfig --namespace $ns --set persistence.enabled=true --set persistence.storageClass=longhorn -f values-grb-g16.yaml cspp-geo-grb cspp-geo-grb/
+    - helm upgrade -v 2 --install --kubeconfig $kubeconfig --namespace $ns $EXTRA_ARGS --set persistence.storageClass=longhorn -f values-grb-g16.yaml cspp-geo-grb cspp-geo-grb/
   dependencies:
     - get_chart_grb
   rules:
diff --git a/admin/README.md b/admin/README.md
index 16253d8..849ceca 100644
--- a/admin/README.md
+++ b/admin/README.md
@@ -111,11 +111,35 @@ Follow the official longhorn installation instructions:
 
 https://longhorn.io/docs/1.0.0/deploy/install/install-with-helm/
 
+Unless newer versions no longer require it, on kubekorner we needed to install
+and enable a iscsi daemon:
+
+```bash
+yum install iscsi-initiator-utils
+systemctl enable iscsid
+systemctl start iscsid
+```
+
 If you have a particular mount on the cluster nodes that has more space than
 the default `/var` path, you may want to customize this setting. For longhorn
 1.0 you can do this by adding `--set defaultSettings.defaultDataPath=/data` to
 your helm install command.
 
+Additionally, if your cluster only has 1 or 2 nodes you may want to change the
+default number of replica volumes longhorn attempts to create. Otherwise, by
+default, longhorn's "hard affinity" will stop volumes from being created since
+it can't make all of the replicas (only one replica per node).
+
+At the time of writing, kubekorner has had its longhorn instance installed with:
+
+```bash
+helm install longhorn ./chart/ --namespace longhorn-system --set defaultSettings.defaultReplicaCount=1 --set persistence.defaultClassReplicaCount=1  --set ingress.enabled=true --set ingress.host="kubekorner.ssec.wisc.edu" --set defaultSettings.defaultDataPath="/data"
+```
+
+From the webUI or following longhorn's current instructions we can change most
+if not all of these settings. If a cluster with one node has more nodes added
+on in the future you may want to consider increasing the replicate count.
+
 ### Storage - Local Large Cache
 
 **DEPRECATED**: See local path provisioner above.
-- 
GitLab