部署

在Kubernetes集群中创建Longhorn的部署非常简单,您可以通过kubectl工具直接运行以下命令镜进行安装。

  1. kubectl --kubeconfig=kube_configxxx.yml apply -f https://raw.githubusercontent.com/rancher/longhorn/master/deploy/longhorn.yml

For Google Kubernetes Engine (GKE) users, see ../gke before proceeding.

Longhorn manager and Longhorn driver will be deployed as daemonsets in a separate namespace called longhorn-system, as you can see in the yaml file.

One of the two available drivers (CSI and Flexvolume) would be chosen automatically based on the environment of the user. User can also override the automatic choice if necessary. See here for the detail.

Noted that the volume created and used through one driver won’t be recongized by Kubernetes using the other driver. So please don’t switch driver (e.g. during upgrade) if you have existing volumes created using the old driver.

When you see those pods have started correctly as follows, you’ve deployed Longhorn successfully.

If Longhorn was deployed with CSI driver (csi-attacher/csi-provisioner/longhorn-csi-plugin exists):

  1. # kubectl --kubeconfig=kube_configxxx.yml -n longhorn-system get pod
  2. NAME READY STATUS RESTARTS AGE
  3. csi-attacher-0 1/1 Running 0 6h
  4. csi-provisioner-0 1/1 Running 0 6h
  5. engine-image-ei-57b85e25-8v65d 1/1 Running 0 7d
  6. engine-image-ei-57b85e25-gjjs6 1/1 Running 0 7d
  7. engine-image-ei-57b85e25-t2787 1/1 Running 0 7d
  8. longhorn-csi-plugin-4cpk2 2/2 Running 0 6h
  9. longhorn-csi-plugin-ll6mq 2/2 Running 0 6h
  10. longhorn-csi-plugin-smlsh 2/2 Running 0 6h
  11. longhorn-driver-deployer-7b5bdcccc8-fbncl 1/1 Running 0 6h
  12. longhorn-manager-7x8x8 1/1 Running 0 6h
  13. longhorn-manager-8kqf4 1/1 Running 0 6h
  14. longhorn-manager-kln4h 1/1 Running 0 6h
  15. longhorn-ui-f849dcd85-cgkgg 1/1 Running 0 5d

Or with FlexVolume driver (longhorn-flexvolume-driver exists):

  1. # kubectl --kubeconfig=kube_configxxx.yml -n longhorn-system get pod
  2. NAME READY STATUS RESTARTS AGE
  3. engine-image-ei-57b85e25-8v65d 1/1 Running 0 7d
  4. engine-image-ei-57b85e25-gjjs6 1/1 Running 0 7d
  5. engine-image-ei-57b85e25-t2787 1/1 Running 0 7d
  6. longhorn-driver-deployer-5469b87b9c-b9gm7 1/1 Running 0 2h
  7. longhorn-flexvolume-driver-lth5g 1/1 Running 0 2h
  8. longhorn-flexvolume-driver-tpqf7 1/1 Running 0 2h
  9. longhorn-flexvolume-driver-v9mrj 1/1 Running 0 2h
  10. longhorn-manager-7x8x8 1/1 Running 0 9h
  11. longhorn-manager-8kqf4 1/1 Running 0 9h
  12. longhorn-manager-kln4h 1/1 Running 0 9h
  13. longhorn-ui-f849dcd85-cgkgg 1/1 Running 0 5d