Install with Fleet

Prerequisites

  • Your workstation: Install Helm v3.0 or later.
  • Kubernetes cluster:

    • Ensure that each node fulfills the installation requirements.

    • Install Fleet using Helm.

      1. helm repo add fleet https://rancher.github.io/fleet-helm-charts/
      2. helm -n cattle-fleet-system install --create-namespace --wait fleet-crd fleet/fleet-crd
      3. helm -n cattle-fleet-system install --create-namespace --wait fleet fleet/fleet

      Allow some time for the deployment of Fleet components in the cattle-fleet-system namespace.

Use this script to check the Longhorn environment for potential issues.

Installing Longhorn

  1. In your GitOps repository, create a fleet.yaml file that includes the following:

    • Parameter for installing Longhorn in the longhorn-system namespace
    1. defaultNamespace: longhorn-system
    1. diff:
    2. comparePatches:
    3. - apiVersion: apiextensions.k8s.io/v1
    4. kind: CustomResourceDefinition
    5. name: engineimages.longhorn.io
    6. operations:
    7. - {"op": "replace", "path": "/status"}
    8. - apiVersion: apiextensions.k8s.io/v1
    9. kind: CustomResourceDefinition
    10. name: nodes.longhorn.io
    11. operations:
    12. - {"op": "replace", "path": "/status"}
    13. - apiVersion: apiextensions.k8s.io/v1
    14. kind: CustomResourceDefinition
    15. name: volumes.longhorn.io
    16. operations:
    17. - {"op": "replace", "path": "/status"}
    • Parameters for specifying the version of the Longhorn Helm chart to be installed
    1. helm:
    2. repo: https://charts.longhorn.io
    3. chart: longhorn
    4. version: v1.6.0 # Replace with the Longhorn version you'd like to install or upgrade to
    5. releaseName: longhorn

    Example of a complete fleet.yaml file:

    1. defaultNamespace: longhorn-system
    2. helm:
    3. repo: https://charts.longhorn.io
    4. chart: longhorn
    5. version: 1.6.0
    6. releaseName: longhorn
    7. diff:
    8. comparePatches:
    9. - apiVersion: apiextensions.k8s.io/v1
    10. kind: CustomResourceDefinition
    11. name: engineimages.longhorn.io
    12. operations:
    13. - {"op": "replace", "path": "/status"}
    14. - apiVersion: apiextensions.k8s.io/v1
    15. kind: CustomResourceDefinition
    16. name: nodes.longhorn.io
    17. operations:
    18. - {"op": "replace", "path": "/status"}
    19. - apiVersion: apiextensions.k8s.io/v1
    20. kind: CustomResourceDefinition
    21. name: volumes.longhorn.io
    22. operations:
    23. - {"op": "replace", "path": "/status"}
  2. Create a GitRepo custom resource (CR) that points to your GitOps repository.

    1. cat > longhorn-gitrepo.yaml << "EOF"
    2. apiVersion: fleet.cattle.io/v1alpha1
    3. kind: GitRepo
    4. metadata:
    5. name: longhorn
    6. namespace: fleet-local
    7. spec:
    8. repo: https://github.com/your-username/your-gitops-repo.git
    9. revision: main
    10. paths:
    11. - .
    12. EOF
  3. Apply the GitRepo CR.

    1. kubectl apply -f longhorn-gitrepo.yaml
  4. Verify that the GitRepo CR was created and synced successfully.

    1. kubectl -n fleet-local get fleet -w
  5. Verify that Longhorn was installed successfully.

    1. kubectl -n longhorn-system get pod

    Example of a successful Longhorn installation:

    1. NAME READY STATUS RESTARTS AGE
    2. longhorn-ui-b7c844b49-w25g5 1/1 Running 0 2m41s
    3. longhorn-manager-pzgsp 1/1 Running 0 2m41s
    4. longhorn-driver-deployer-6bd59c9f76-lqczw 1/1 Running 0 2m41s
    5. longhorn-csi-plugin-mbwqz 2/2 Running 0 100s
    6. csi-snapshotter-588457fcdf-22bqp 1/1 Running 0 100s
    7. csi-snapshotter-588457fcdf-2wd6g 1/1 Running 0 100s
    8. csi-provisioner-869bdc4b79-mzrwf 1/1 Running 0 101s
    9. csi-provisioner-869bdc4b79-klgfm 1/1 Running 0 101s
    10. csi-resizer-6d8cf5f99f-fd2ck 1/1 Running 0 101s
    11. csi-provisioner-869bdc4b79-j46rx 1/1 Running 0 101s
    12. csi-snapshotter-588457fcdf-bvjdt 1/1 Running 0 100s
    13. csi-resizer-6d8cf5f99f-68cw7 1/1 Running 0 101s
    14. csi-attacher-7bf4b7f996-df8v6 1/1 Running 0 101s
    15. csi-attacher-7bf4b7f996-g9cwc 1/1 Running 0 101s
    16. csi-attacher-7bf4b7f996-8l9sw 1/1 Running 0 101s
    17. csi-resizer-6d8cf5f99f-smdjw 1/1 Running 0 101s
    18. instance-manager-b34d5db1fe1e2d52bcfb308be3166cfc 1/1 Running 0 114s
    19. engine-image-ei-df38d2e5-cv6nc 1/1 Running 0 114s
  6. Create an NGINX Ingress controller with basic authentication to access the Longhorn UI. Authentication to the Longhorn UI is not enabled by default.

  7. Access the Longhorn UI.


© 2019-2024 Longhorn Authors | Documentation Distributed under CC-BY-4.0