From 6454bd3fa87b4dda51ac0388e6d48bdaf10e2868 Mon Sep 17 00:00:00 2001 From: James Oliver Date: Fri, 11 Jan 2019 12:08:02 -0700 Subject: [PATCH] Update uninstallation procedure, synchronize chart doc --- README.md | 31 ++++++++++++++++++------------- deploy/uninstall.yaml | 27 +++++++++++++++++++++++++++ docs/chart.md | 22 +++++++--------------- 3 files changed, 52 insertions(+), 28 deletions(-) create mode 100644 deploy/uninstall.yaml diff --git a/README.md b/README.md index b3f0e30..a469dc2 100644 --- a/README.md +++ b/README.md @@ -260,24 +260,29 @@ See [here](./docs/troubleshooting.md) for the troubleshooting guide. ## Uninstall Longhorn -Longhorn stores its data in the Kubernetes API server, in the format of CRD. Longhorn CRDs have finalizers; user should delete the volumes and related resource first to give the managers a chance to clean up. +1. To prevent damage to the Kubernetes cluster, we recommend deleting all Kubernetes workloads using Longhorn volumes (PersistentVolume, PersistentVolumeClaim, StorageClass, Deployment, StatefulSet, DaemonSet, etc). -Before uninstalling Longhorn, the user need to delete all the PVC and PV resources which refer to a Longhorn volume in Kubernetes. Otherwise, Kubernetes may get confused because the underlying storage is gone but the PV/PVC remains. - -### 1. Run cleanup script -Note that you will lose all volume data after done this. If you intend on keeping any volume data, make backups (and test restoring a volume) before proceeding. +2. Create the uninstallation job to cleanly purge CRDs from the system and wait for success: + ``` + kubectl create -f https://raw.githubusercontent.com/rancher/longhorn/master/deploy/uninstall.yaml + kubectl -n longhorn-system get job/longhorn-uninstall -w + ``` +Example output: ``` -curl -sSfL https://raw.githubusercontent.com/rancher/longhorn-manager/master/deploy/scripts/cleanup.sh | bash +$ kubectl create -f https://raw.githubusercontent.com/rancher/longhorn/master/deploy/uninstall.yaml +job.batch/longhorn-uninstall created +$ kubectl -n longhorn-system get job/longhorn-uninstall -w +NAME DESIRED SUCCESSFUL AGE +longhorn-uninstall 1 0 3s +longhorn-uninstall 1 1 45s +^C ``` -### 2. Delete remaining components - -The cleanup script removes most components, but leaves RBAC related resources and the `longhorn-system` Namespace behind. Run this command to remove these resources. - -``` -kubectl delete -f https://raw.githubusercontent.com/rancher/longhorn/master/deploy/longhorn.yaml -``` +3. Remove remaining components: + ``` + kubectl delete -f https://raw.githubusercontent.com/rancher/longhorn/master/deploy/longhorn.yaml + ``` ## License diff --git a/deploy/uninstall.yaml b/deploy/uninstall.yaml new file mode 100644 index 0000000..befbf94 --- /dev/null +++ b/deploy/uninstall.yaml @@ -0,0 +1,27 @@ +apiVersion: batch/v1 +kind: Job +metadata: + name: longhorn-uninstall + namespace: longhorn-system +spec: + activeDeadlineSeconds: 900 + backoffLimit: 1 + template: + metadata: + name: longhorn-uninstall + spec: + containers: + - name: longhorn-uninstall + image: rancher/longhorn-manager:v0.3.2 + imagePullPolicy: Always + command: + - longhorn-manager + - uninstall + - --force + env: + - name: POD_NAMESPACE + valueFrom: + fieldRef: + fieldPath: metadata.namespace + restartPolicy: OnFailure + serviceAccountName: longhorn-service-account diff --git a/docs/chart.md b/docs/chart.md index cbc00f9..26af79b 100644 --- a/docs/chart.md +++ b/docs/chart.md @@ -2,8 +2,6 @@ The following document pertains to running Longhorn from the Rancher 2.0 chart. -Noted it's recommended to install Longhorn app in a separate Rancher Project, e.g. `Storage` or `Longhorn`. - ## Source Code Longhorn is 100% open source software. Project source code is spread across a number of repos: @@ -14,23 +12,17 @@ Longhorn is 100% open source software. Project source code is spread across a nu ## Prerequisites -1. Docker v1.13+ -2. Kubernetes v1.8+ cluster with 1 or more nodes and Mount Propagation feature enabled. If your Kubernetes cluster was provisioned by Rancher v2.0.7+ or later, MountPropagation feature is enabled by default. [Check your Kubernetes environment now](https://github.com/rancher/longhorn#environment-check-script). If MountPropagation is disabled, the Kubernetes Flexvolume driver will be deployed instead of the default CSI driver. Base Image feature will also be disabled if MountPropagation is disabled. -3. Make sure `curl`, `findmnt`, `grep`, `awk` and `blkid` has been installed in all nodes of the Kubernetes cluster. -4. Make sure `open-iscsi` has been installed in all nodes of the Kubernetes cluster. For GKE, recommended Ubuntu as guest OS image since it contains `open-iscsi` already. +1. Rancher v2.1+ +2. Docker v1.13+ +3. Kubernetes v1.8+ cluster with 1 or more nodes and Mount Propagation feature enabled. If your Kubernetes cluster was provisioned by Rancher v2.0.7+ or later, MountPropagation feature is enabled by default. [Check your Kubernetes environment now](https://github.com/rancher/longhorn#environment-check-script). If MountPropagation is disabled, the Kubernetes Flexvolume driver will be deployed instead of the default CSI driver. Base Image feature will also be disabled if MountPropagation is disabled. +4. Make sure `curl`, `findmnt`, `grep`, `awk` and `blkid` has been installed in all nodes of the Kubernetes cluster. +5. Make sure `open-iscsi` has been installed in all nodes of the Kubernetes cluster. For GKE, recommended Ubuntu as guest OS image since it contains `open-iscsi` already. ## Uninstallation -**Do not attempt to immediately delete Longhorn App from Rancher UI. Longhorn propagates device mounts which can damage the host if not unmounted properly.** Follow this procedure instead. - 1. To prevent damage to the Kubernetes cluster, we recommend deleting all Kubernetes workloads using Longhorn volumes (PersistentVolume, PersistentVolumeClaim, StorageClass, Deployment, StatefulSet, DaemonSet, etc). -2. [Rancher v2.0.x users only] From the `Cluster` tab, click `Launch kubectl` and run this command: - ``` - curl -sSfL https://raw.githubusercontent.com/rancher/longhorn-manager/master/deploy/scripts/cleanup.sh | bash - ``` - -3. From Rancher UI, navigate to `Catalog Apps` tab and delete Longhorn app. +2. From Rancher UI, navigate to `Catalog Apps` tab and delete Longhorn app. ## Troubleshooting @@ -59,7 +51,7 @@ By default, Kubernetes uses `/usr/libexec/kubernetes/kubelet-plugins/volume/exec Some vendors choose to change the directory for various reasons. For example, GKE uses `/home/kubernetes/flexvolume` instead. -If you don't know what the correct directory is for your cluster, please leave the Chart question blank. +User can find the correct directory by running `ps aux|grep kubelet` on the host and check the `--volume-plugin-dir` parameter. If there is none, the default `/usr/libexec/kubernetes/kubelet-plugins/volume/exec/` will be used. --- Please see [link](https://github.com/rancher/longhorn) for more information.