Install with Flux

Prerequisites

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

    • Ensure that each node fulfills the installation requirements.

    • Install the Flux CLI.

    • Bootstrap Flux with GitHub using the Flux CLI. Run the following commands to export your GitHub personal access token (PAT) as an environment variable, deploy the Flux controllers on your cluster, and configure the controllers to sync the cluster state from the specified GitHub repository.

      1. export GITHUB_TOKEN=<gh-token>
      2. flux bootstrap github \
      3. --token-auth \
      4. --owner=<github_username> \
      5. --repository=<github_repo_name> \
      6. --branch=<branch_name> \
      7. --path=<folder_path_within_repo> \
      8. --personal

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

Installing Longhorn

  1. Create a HelmRepository custom resource (CR) that points to the Longhorn Helm chart URL.

    1. kubectl create ns longhorn-system
    2. flux create source helm longhorn-repo \
    3. --url=https://charts.longhorn.io \
    4. --namespace=longhorn-system \
    5. --export > helmrepo.yaml
  2. Create a HelmRelease CR that references the HelmRepository and specifies the version of the Longhorn Helm chart to be installed.

    1. flux create helmrelease longhorn-release \
    2. --chart=longhorn \
    3. --source=HelmRepository/longhorn-repo \
    4. --chart-version=1.6.0 \
    5. --namespace=longhorn-system \
    6. --export > helmrelease.yaml
  3. Verify that the HelmRelease CR was created and synced successfully.

    1. flux get helmrelease longhorn-release -n longhorn-system
  4. 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
  5. Create an NGINX Ingress controller with basic authentication to access the Longhorn UI. Authentication to the Longhorn UI is not enabled by default.

  6. Access the Longhorn UI.

Continuous Operations via GitOps

You can commit and push exported manifests to your GitOps repository.

  1. ```bash
  2. git add helmrepo.yaml helmrelease.yaml
  3. git commit -m "Add HelmRepository and HelmRelease for Longhorn installation"
  4. git push origin <branch_name>
  5. ```

Afterwards, you can modify the HelmRelease and HelmRepository CRs by editing the YAML manifests in your GitOps repository. Flux automatically detects and applies the changes without requiring direct access to your Kubernetes cluster.


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