OCP/OKD Support

To deploy Longhorn on a cluster provisioned with OpenShift 4.x, some additional configurations are required.

Note: OKD currently does not support the ARM platform. For more information, see the OKD website and GitHub issue #1165 (OKD in ARM platform).

Install Longhorn

Install With Helm

Please refer to this section Install with Helm first.

Install Longhorn with the following settings:

SettingValueExample
openshift.enabledtrueN/A
image.openshift.oauthProxy.repositoryUpstream imagequay.io/openshift/origin-oauth-proxy
image.openshift.oauthProxy.tagVersion 4.1 or later4.15
  1. helm install longhorn longhorn/longhorn \
  2. --namespace longhorn-system \
  3. --create-namespace \
  4. --set openshift.enabled=true \
  5. --set image.openshift.oauthProxy.repository=quay.io/openshift/origin-oauth-proxy \
  6. --set image.openshift.oauthProxy.tag=4.15

Install With oc Command

Perform the following steps to install Longhorn on OKD clusters.

  1. Download the longhorn-okd.yaml file.
  1. wget https://raw.githubusercontent.com/longhorn/longhorn/v1.7.2/deploy/longhorn-okd.yaml
  1. Specify the target oauth-proxy container image in the longhorn-okd.yaml file (for example, quay.io/openshift/origin-oauth-proxy:4.15).

  2. Run the following command:

  1. oc apply -f longhorn-okd.yaml

One way to monitor the progress of the installation is to watch pods being created in the longhorn-system namespace:

  1. oc get pods \
  2. --namespace longhorn-system \
  3. --watch

For more information, see Install with Kubectl.

Prepare A Customized Default Longhorn Disk (Optional)

To understand more about configuring the disks for Longhorn, please refer to the section Configuring Defaults for Nodes and Disks

Longhorn will use the directory /var/lib/longhorn as default storage mount point and that means Longhorn use the root device as the default storage. If you don’t want to use the root device as the Longhorn storage, set defaultSettings.createDefaultDiskLabeledNodes true when installing Longhorn by helm:

  1. --set defaultSettings.createDefaultDiskLabeledNodes=true

And then add another device formatted to Longhorn storage

Add An Extra Disk to Longhorn Storage

Create Filesystem For The Device

Create the filesystem on the device with the label longhorn on the storage node. Get into the node by oc command:

  1. oc get nodes --no-headers | awk '{print $1}'
  2. oc debug node/${NODE_NAME} -t -- chroot /host bash

Check if the device is present and format it with Longhorn label:

  1. lsblk
  2. sudo mkfs.ext4 -L longhorn /dev/${DEVICE_NAME}

Mounting The Device On Boot with MachineConfig CRD

The secondary drive needs to be mounted automatically when node boots up by the MachineConfig that can be created and deployed by:

  1. cat <<EOF >>auto-mount-machineconfig.yaml
  2. apiVersion: machineconfiguration.openshift.io/v1
  3. kind: MachineConfig
  4. metadata:
  5. labels:
  6. machineconfiguration.openshift.io/role: worker
  7. name: 71-mount-storage-worker
  8. spec:
  9. config:
  10. ignition:
  11. version: 3.2.0
  12. systemd:
  13. units:
  14. - name: var-mnt-longhorn.mount
  15. enabled: true
  16. contents: |
  17. [Unit]
  18. Before=local-fs.target
  19. [Mount]
  20. # Example mount point, you can change it to where you like for each device.
  21. Where=/var/mnt/longhorn
  22. What=/dev/disk/by-label/longhorn
  23. Options=rw,relatime,discard
  24. [Install]
  25. WantedBy=local-fs.target
  26. EOF
  27. oc apply -f auto-mount-machineconfig.yaml

Label and Annotate The Node

Please refer to the section Customizing Default Disks for New Nodes to label and annotate storage node on where your device is by oc commands:

  1. oc get nodes --no-headers | awk '{print $1}'
  2. oc annotate node ${NODE_NAME} --overwrite node.longhorn.io/default-disks-config='[{"path":"/var/mnt/longhorn","allowScheduling":true}]'
  3. oc label node ${NODE_NAME} --overwrite node.longhorn.io/create-default-disk=config

Note: You might need to reboot the node to validate the modified configuration.

Reference

Main Contributor