longhorn/README.md

217 lines
9.5 KiB
Markdown
Raw Normal View History

2017-04-14 23:16:53 +00:00
# Longhorn
2019-04-02 18:43:13 +00:00
Longhorn is a cloud native distributed block storage system for Kubernetes.
2017-04-16 07:25:39 +00:00
2019-04-02 18:43:13 +00:00
Longhorn is lightweight, reliable, and powerful. You can install Longhorn on an existing Kubernetes cluster with one line of command or using Rancher Catalog App/Helm. Once Longhorn is installed, it adds persistent volume support to the Kubernetes cluster.
Longhorn implements distributed block storage using containers and microservices. Longhorn creates a dedicated storage controller for each block device volume and sychronously replicates the volume across multiple replicas stored on multiple nodes. The storage controller and replicas are themselves orchestrated using Kubernetes. Longhorn supports snapshots, backups, scheduling recurring snapshots and backups, non disruptive upgrade, and more.
2017-04-14 23:16:53 +00:00
You can read more details of Longhorn and its design [here](http://rancher.com/microservices-block-storage/).
2017-04-21 07:17:27 +00:00
2018-08-23 22:08:22 +00:00
## Current status
Longhorn is a work in progress. It's an alpha quality software at the moment. We appreciate your comments as we continue to work on it.
The latest release of Longhorn is **v0.4.1**, shipped with Longhorn Engine **v0.4.1** as the default engine image.
2017-04-14 23:16:53 +00:00
2018-08-23 00:28:06 +00:00
## Source code
2017-04-27 20:15:23 +00:00
Longhorn is 100% open source software. Project source code is spread across a number of repos:
2017-04-27 20:12:32 +00:00
2018-08-23 00:28:06 +00:00
1. Longhorn engine -- Core controller/replica logic https://github.com/rancher/longhorn-engine
2018-09-14 00:47:44 +00:00
1. Longhorn manager -- Longhorn orchestration, includes Flexvolume driver for Kubernetes https://github.com/rancher/longhorn-manager
2017-04-27 20:12:32 +00:00
1. Longhorn UI -- Dashboard https://github.com/rancher/longhorn-ui
2019-04-02 18:43:13 +00:00
![Longhorn UI](https://s3-us-west-1.amazonaws.com/rancher-longhorn/LonghornUI.png)
2018-03-26 22:11:48 +00:00
2018-08-02 03:38:51 +00:00
# Requirements
2018-08-02 03:38:51 +00:00
## Minimal Requirements
2018-08-02 03:38:51 +00:00
1. Docker v1.13+
2019-04-02 18:43:13 +00:00
2. Kubernetes v1.8+. Recommend v1.12+.
3. `open-iscsi` has been installed on all the nodes of the Kubernetes cluster.
2019-04-02 02:23:24 +00:00
1. For GKE, recommended Ubuntu as guest OS image since it contains open-iscsi already.
2. For Debian/Ubuntu, use `apt-get install open-iscsi` to install.
3. For RHEL/CentOS, use `yum install iscsi-initiator-utils` to install.
2019-04-02 02:23:24 +00:00
# Install
2018-09-14 00:47:44 +00:00
2019-04-02 02:23:24 +00:00
## Using Longhorn App on Rancher 2.1 or newer
2018-09-14 00:47:44 +00:00
2019-04-02 02:31:45 +00:00
If you're using Rancher 2.1 or newer, you can install Longhorn using Rancher Catalog Apps.
2019-04-02 02:23:24 +00:00
1. On Rancher UI, select the cluster and project you want to install Longhorn on. We recommended to create a new project e.g. `Storage` for Longhorn.
2019-04-02 02:31:45 +00:00
2. Navigate to the `Catalog Apps` screen. Select `Launch`, find Longhorn in the list. Select `View Details`, then click `Launch`
2019-04-02 02:26:55 +00:00
1. Longhorn will always be installed on `longhorn-system` namespace.
2019-04-02 18:43:13 +00:00
2. Since v0.3.2, Longhorn App will use Rancher Proxy for UI by default, so Rancher can provide authentication to Longhorn UI.
After Longhorn has been successfully installed, you can access the Longhorn UI by navigating to the `Catalog Apps` screen.
If there is a new version of Longhorn available, you will also see `Upgrade Available` sign on the `Catalog Apps` screen. You can click `Upgrade` button to upgrade Longhorn manager here. See more about upgrade [here](#upgrade).
2018-09-14 00:47:44 +00:00
2019-04-02 02:23:24 +00:00
## Using YAML file
2018-09-14 00:47:44 +00:00
2019-04-02 02:23:24 +00:00
You can install the latest Longhorn in your Kubernetes cluster using following command:
2018-08-02 03:38:51 +00:00
```
kubectl apply -f https://raw.githubusercontent.com/rancher/longhorn/master/deploy/longhorn.yaml
```
For Google Kubernetes Engine (GKE) users, see [here](docs/gke.md) before proceeding.
2017-04-14 23:16:53 +00:00
2019-04-02 02:30:53 +00:00
Longhorn will be installed in the namespace `longhorn-system`
2017-04-14 23:16:53 +00:00
2019-04-02 02:30:53 +00:00
One of the two available drivers (CSI and Flexvolume) would be chosen automatically based on the environment. See [here](docs/driver.md) for the detail.
2019-04-02 02:30:53 +00:00
The following shows a success deployment with CSI driver:
```
# kubectl -n longhorn-system get pod
2018-08-02 03:38:51 +00:00
NAME READY STATUS RESTARTS AGE
csi-attacher-0 1/1 Running 0 6h
csi-provisioner-0 1/1 Running 0 6h
engine-image-ei-57b85e25-8v65d 1/1 Running 0 7d
engine-image-ei-57b85e25-gjjs6 1/1 Running 0 7d
engine-image-ei-57b85e25-t2787 1/1 Running 0 7d
longhorn-csi-plugin-4cpk2 2/2 Running 0 6h
longhorn-csi-plugin-ll6mq 2/2 Running 0 6h
longhorn-csi-plugin-smlsh 2/2 Running 0 6h
longhorn-driver-deployer-7b5bdcccc8-fbncl 1/1 Running 0 6h
longhorn-manager-7x8x8 1/1 Running 0 6h
longhorn-manager-8kqf4 1/1 Running 0 6h
longhorn-manager-kln4h 1/1 Running 0 6h
longhorn-ui-f849dcd85-cgkgg 1/1 Running 0 5d
```
2019-04-02 02:26:55 +00:00
### Accessing the UI
2018-08-02 03:38:51 +00:00
Use `kubectl -n longhorn-system get svc` to get the external service IP for UI:
2017-04-14 23:16:53 +00:00
```
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
longhorn-backend ClusterIP 10.20.248.250 <none> 9500/TCP 58m
2019-04-02 18:43:13 +00:00
longhorn-frontend LoadBalancer 10.20.245.110 100.200.200.123 80:30697/TCP 58m
2018-08-02 03:38:51 +00:00
2017-04-14 23:16:53 +00:00
```
2018-08-02 03:38:51 +00:00
If the Kubernetes Cluster supports creating LoadBalancer, user can then use `EXTERNAL-IP`(`100.200.200.123` in the case above) of `longhorn-frontend` to access the Longhorn UI. Otherwise the user can use `<node_ip>:<port>` (port is `30697`in the case above) to access the UI.
2019-04-02 18:43:13 +00:00
Noted that the UI is unauthenticated when you installed Longhorn using YAML file.
2019-04-02 02:23:24 +00:00
# Upgrade
2019-04-02 18:43:13 +00:00
Since v0.3.3, Longhorn is able to perform non disruptive upgrade, meaning the upgrade process of Longhorn won't impact the accessibility of existing volumes.
2019-04-02 02:23:24 +00:00
If you're upgrading from Longhorn v0.3.0 or newer:
2019-04-02 02:28:23 +00:00
1. Follow [the same steps for installation](#install) to upgrade Longhorn manager
2019-04-02 18:43:13 +00:00
2. After upgraded manager, follow [the steps here](docs/upgrade.md#upgrade-longhorn-engine) to upgrade Longhorn engine for existing volumes.
1. For non distruptive upgrade, follow [the live upgrade steps here](./docs/upgrade.md#live-upgrade)
2019-04-02 02:23:24 +00:00
For more details about upgrade in Longhorn or upgrade from older versions, [see here](docs/upgrade.md).
2019-04-02 02:23:24 +00:00
# Use Longhorn volumes for Kubernetes
2018-08-02 03:38:51 +00:00
Use following command to create a default Longhorn StorageClass named `longhorn`.
```
kubectl create -f https://raw.githubusercontent.com/rancher/longhorn/master/examples/storageclass.yaml
```
Now you can create a pod using Longhorn like this:
```
kubectl create -f https://raw.githubusercontent.com/rancher/longhorn/master/examples/pvc.yaml
```
The yaml contains two parts:
1. Create a PVC using Longhorn StorageClass.
2017-04-14 23:16:53 +00:00
```
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: longhorn-volv-pvc
spec:
accessModes:
- ReadWriteOnce
storageClassName: longhorn
resources:
requests:
storage: 2Gi
2017-04-14 23:16:53 +00:00
```
2. Use it in the a Pod as a persistent volume:
2017-04-14 23:16:53 +00:00
```
apiVersion: v1
kind: Pod
metadata:
name: volume-test
namespace: default
spec:
containers:
- name: volume-test
image: nginx:stable-alpine
imagePullPolicy: IfNotPresent
volumeMounts:
- name: volv
mountPath: /data
ports:
- containerPort: 80
volumes:
- name: volv
persistentVolumeClaim:
claimName: longhorn-volv-pvc
2017-04-14 23:16:53 +00:00
```
2018-08-02 03:38:51 +00:00
More examples are available at `./examples/`
2019-04-02 02:23:24 +00:00
## Feature manuals
### [Snapshot and Backup](./docs/snapshot-backup.md)
### [Volume operations](./docs/volume.md)
2018-08-23 00:28:06 +00:00
### [Multiple disks](./docs/multidisk.md)
### [iSCSI](./docs/iscsi.md)
### [Base image](./docs/base-image.md)
2017-04-14 23:16:53 +00:00
2019-04-02 02:23:24 +00:00
## Usage guides
### [Restoring Stateful Set volumes](./docs/restore_statefulset.md)
2018-08-22 19:36:59 +00:00
### [Google Kubernetes Engine](./docs/gke.md)
### [Deal with Kubernetes node failure](./docs/node-failure.md)
### [Use CSI driver on RancherOS/CoreOS + RKE or K3S](./docs/csi-config.md)
2019-03-23 01:31:52 +00:00
### [Restore a backup to an image file](./docs/restore-to-file.md)
## Troubleshooting
2019-02-22 19:41:56 +00:00
You can click `Generate Support Bundle` link at the bottom of the UI to download a zip file contains Longhorn related configuration and logs.
See [here](./docs/troubleshooting.md) for the troubleshooting guide.
2018-08-22 19:36:59 +00:00
2018-08-02 03:38:51 +00:00
## Uninstall Longhorn
2019-04-02 18:43:13 +00:00
1. To prevent damaging the Kubernetes cluster, we recommend deleting all Kubernetes workloads using Longhorn volumes (PersistentVolume, PersistentVolumeClaim, StorageClass, Deployment, StatefulSet, DaemonSet, etc) first.
2017-04-14 23:16:53 +00:00
2019-04-02 18:43:13 +00:00
2. Create the uninstallation job to clean up CRDs from the system and wait for success:
```
2019-01-12 02:00:25 +00:00
kubectl create -f https://raw.githubusercontent.com/rancher/longhorn/master/uninstall/uninstall.yaml
kubectl -n longhorn-system get job/longhorn-uninstall -w
```
Example output:
2017-04-14 23:16:53 +00:00
```
2019-01-12 02:00:25 +00:00
$ kubectl create -f https://raw.githubusercontent.com/rancher/longhorn/master/uninstall/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
```
2017-04-16 07:25:39 +00:00
3. Remove remaining components:
```
kubectl delete -f https://raw.githubusercontent.com/rancher/longhorn/master/deploy/longhorn.yaml
```
2017-04-16 07:25:39 +00:00
## License
2019-01-15 18:21:05 +00:00
Copyright (c) 2014-2019 [Rancher Labs, Inc.](http://rancher.com/)
2018-08-02 03:38:51 +00:00
Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
2017-04-16 07:25:39 +00:00
[http://www.apache.org/licenses/LICENSE-2.0](http://www.apache.org/licenses/LICENSE-2.0)
2018-08-02 03:38:51 +00:00
Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.