Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

doc(os/distro): OCP/OKD support #765

Merged
merged 1 commit into from
Sep 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,114 @@
---
title: OCP/OKD Support
weight: 4
---

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

- [Install Longhorn](#install-longhorn)
- [Prepare A Customized Default Longhorn Disk (Optional)](#prepare-a-customized-default-longhorn-disk-optional)
- [Add An Extra Disk to Longhorn Storage](#add-an-extra-disk-to-longhorn-storage)
- [Create Filesystem For The Device](#create-filesystem-for-the-device)
- [Mounting The Device On Boot with MachineConfig CRD](#mounting-the-device-on-boot-with-machineconfig-crd)
- [Label and Annotate The Node](#label-and-annotate-the-node)
- [Reference](#reference)
- [Main Contributor](#main-contributor)

## Install Longhorn

Please refer to this section [Install with Helm](../../../deploy/install/install-with-helm/) first.

And then install Longhorn with setting ***openshift.enabled*** true:

```bash
helm install longhorn longhorn/longhorn --namespace longhorn-system --create-namespace --set openshift.enabled=true
```

## 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](../../../advanced-resources/default-disk-and-node-config/#launch-longhorn-with-multiple-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:

```txt
--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:

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

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

```bash
lsblk
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:

```bash
cat <<EOF >>auto-mount-machineconfig.yaml
apiVersion: machineconfiguration.openshift.io/v1
kind: MachineConfig
metadata:
labels:
machineconfiguration.openshift.io/role: worker
name: 71-mount-storage-worker
spec:
config:
ignition:
version: 3.2.0
systemd:
units:
- name: var-mnt-longhorn.mount
enabled: true
contents: |
[Unit]
Before=local-fs.target
[Mount]
# Example mount point, you can change it to where you like for each device.
Where=/var/mnt/longhorn
What=/dev/disk/by-label/longhorn
Options=rw,relatime,discard
[Install]
WantedBy=local-fs.target
EOF

oc apply -f auto-mount-machineconfig.yaml
```

#### Label and Annotate The Node

Please refer to the section [Customizing Default Disks for New Nodes](../../../advanced-resources/default-disk-and-node-config/#customizing-default-disks-for-new-nodes) to label and annotate storage node on where your device is by oc commands:

```bash
oc get nodes --no-headers | awk '{print $1}'

oc annotate node ${NODE_NAME} --overwrite node.longhorn.io/default-disks-config='[{"path":"/var/mnt/longhorn","allowScheduling":true}]'
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

- [OCP/OKD Documentation and Helm Support](https://github.com/longhorn/longhorn/pull/5004)
- [OKD Official Website](https://www.okd.io/)
- [OKD Official Documentation Website](https://docs.okd.io/latest/welcome/index.html)
- [oauth-proxy](https://github.com/openshift/oauth-proxy/blob/master/contrib/sidecar.yaml)

## Main Contributor

- [@ArthurVardevanyan](https://github.com/ArthurVardevanyan)
3 changes: 1 addition & 2 deletions content/docs/1.6.0/deploy/install/_index.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@ For the minimum recommended hardware, refer to the [best practices guide.](../..
- **Google Kubernetes Engine (GKE)** requires some additional setup for Longhorn to function properly. If you're a GKE user, refer to [this section](../../advanced-resources/os-distro-specific/csi-on-gke) for details.
- **K3s clusters** require some extra setup. Refer to [this section](../../advanced-resources/os-distro-specific/csi-on-k3s)
- **RKE clusters with CoreOS** need [this configuration.](../../advanced-resources/os-distro-specific/csi-on-rke-and-coreos)
- **OCP/OKD clusters** require some extra setup. Refer to [this section](../../advanced-resources/os-distro-specific/okd-support)

### Using the Environment Check Script

Expand Down Expand Up @@ -250,5 +251,3 @@ Server Version: version.Info{Major:"1", Minor:"21", GitVersion:"v1.21.0+k3s1", G
```

The `Server Version` should be >= v1.21.