| gio | dbf4a85 | 2025-06-30 17:09:46 +0400 | [diff] [blame] | 1 | # OpenShift / OKD Extra Configuration Steps |
| 2 | |
| 3 | - [OpenShift / OKD Extra Configuration Steps](#openshift--okd-extra-configuration-steps) |
| 4 | - [Notes](#notes) |
| 5 | - [Known Issues](#known-issues) |
| 6 | - [Preparing Nodes (Optional)](#preparing-nodes-optional) |
| 7 | - [Default /var/lib/longhorn setup](#default-varliblonghorn-setup) |
| 8 | - [Separate /var/mnt/longhorn setup](#separate-varmntlonghorn-setup) |
| 9 | - [Create Filesystem](#create-filesystem) |
| 10 | - [Mounting Disk On Boot](#mounting-disk-on-boot) |
| 11 | - [Label and Annotate Nodes](#label-and-annotate-nodes) |
| 12 | - [Example values.yaml](#example-valuesyaml) |
| 13 | - [Installation](#installation) |
| 14 | - [Refs](#refs) |
| 15 | |
| 16 | ## Notes |
| 17 | |
| 18 | Main changes and tasks for OCP are: |
| 19 | |
| 20 | - On OCP / OKD, the Operating System is Managed by the Cluster |
| 21 | - OCP Imposes [Security Context Constraints](https://docs.openshift.com/container-platform/4.11/authentication/managing-security-context-constraints.html) |
| 22 | - This requires everything to run with the least privilege possible. For the moment every component has been given access to run as higher privilege. |
| 23 | - Something to circle back on is network polices and which components can have their privileges reduced without impacting functionality. |
| 24 | - The UI probably can be for example. |
| 25 | - openshift/oauth-proxy for authentication to the Longhorn Ui |
| 26 | - **⚠️** Currently Scoped to Authenticated Users that can delete a longhorn settings object. |
| 27 | - **⚠️** Since the UI it self is not protected, network policies will need to be created to prevent namespace <--> namespace communication against the pod or service object directly. |
| 28 | - Anyone with access to the UI Deployment can remove the route restriction. (Namespace Scoped Admin) |
| 29 | - Option to use separate disk in /var/mnt/longhorn & MachineConfig file to mount /var/mnt/longhorn |
| 30 | - Adding finalizers for mount propagation |
| 31 | |
| 32 | ## Known Issues |
| 33 | |
| 34 | - General Feature/Issue Thread |
| 35 | - [[FEATURE] Deploying Longhorn on OKD/Openshift](https://github.com/longhorn/longhorn/issues/1831) |
| 36 | - 4.10 / 1.23: |
| 37 | - 4.10.0-0.okd-2022-03-07-131213 to 4.10.0-0.okd-2022-07-09-073606 |
| 38 | - Tested, No Known Issues |
| 39 | - 4.11 / 1.24: |
| 40 | - 4.11.0-0.okd-2022-07-27-052000 to 4.11.0-0.okd-2022-11-19-050030 |
| 41 | - Tested, No Known Issues |
| 42 | - 4.11.0-0.okd-2022-12-02-145640, 4.11.0-0.okd-2023-01-14-152430: |
| 43 | - Workaround: [[BUG] Volumes Stuck in Attach/Detach Loop](https://github.com/longhorn/longhorn/issues/4988) |
| 44 | - [MachineConfig Patch](https://github.com/longhorn/longhorn/issues/4988#issuecomment-1345676772) |
| 45 | - 4.12 / 1.25: |
| 46 | - 4.12.0-0.okd-2022-12-05-210624 to 4.12.0-0.okd-2023-01-20-101927 |
| 47 | - Tested, No Known Issues |
| 48 | - 4.12.0-0.okd-2023-01-21-055900 to 4.12.0-0.okd-2023-02-18-033438: |
| 49 | - Workaround: [[BUG] Volumes Stuck in Attach/Detach Loop](https://github.com/longhorn/longhorn/issues/4988) |
| 50 | - [MachineConfig Patch](https://github.com/longhorn/longhorn/issues/4988#issuecomment-1345676772) |
| 51 | - 4.12.0-0.okd-2023-03-05-022504 - 4.12.0-0.okd-2023-04-16-041331: |
| 52 | - Tested, No Known Issues |
| 53 | - 4.13 / 1.26: |
| 54 | - 4.13.0-0.okd-2023-05-03-001308 - 4.13.0-0.okd-2023-08-18-135805: |
| 55 | - Tested, No Known Issues |
| 56 | - 4.14 / 1.27: |
| 57 | - 4.14.0-0.okd-2023-08-12-022330 - 4.14.0-0.okd-2023-10-28-073550: |
| 58 | - Tested, No Known Issues |
| 59 | |
| 60 | ## Preparing Nodes (Optional) |
| 61 | |
| 62 | Only required if you require additional customizations, such as storage-less nodes, or secondary disks. |
| 63 | |
| 64 | ### Default /var/lib/longhorn setup |
| 65 | |
| 66 | Label each node for storage with: |
| 67 | |
| 68 | ```bash |
| 69 | oc get nodes --no-headers | awk '{print $1}' |
| 70 | |
| 71 | export NODE="worker-0" |
| 72 | oc label node "${NODE}" node.longhorn.io/create-default-disk=true |
| 73 | ``` |
| 74 | |
| 75 | ### Separate /var/mnt/longhorn setup |
| 76 | |
| 77 | #### Create Filesystem |
| 78 | |
| 79 | On the storage nodes create a filesystem with the label longhorn: |
| 80 | |
| 81 | ```bash |
| 82 | oc get nodes --no-headers | awk '{print $1}' |
| 83 | |
| 84 | export NODE="worker-0" |
| 85 | oc debug node/${NODE} -t -- chroot /host bash |
| 86 | |
| 87 | # Validate Target Drive is Present |
| 88 | lsblk |
| 89 | |
| 90 | export DRIVE="sdb" #vdb |
| 91 | sudo mkfs.ext4 -L longhorn /dev/${DRIVE} |
| 92 | ``` |
| 93 | |
| 94 | > ⚠️ Note: If you add New Nodes After the below Machine Config is applied, you will need to also reboot the node. |
| 95 | |
| 96 | #### Mounting Disk On Boot |
| 97 | |
| 98 | The Secondary Drive needs to be mounted on every boot. Save the Concents and Apply the MachineConfig with `oc apply -f`: |
| 99 | |
| 100 | > ⚠️ This will trigger an machine config profile update and reboot all worker nodes on the cluster |
| 101 | |
| 102 | ```yaml |
| 103 | apiVersion: machineconfiguration.openshift.io/v1 |
| 104 | kind: MachineConfig |
| 105 | metadata: |
| 106 | labels: |
| 107 | machineconfiguration.openshift.io/role: worker |
| 108 | name: 71-mount-storage-worker |
| 109 | spec: |
| 110 | config: |
| 111 | ignition: |
| 112 | version: 3.2.0 |
| 113 | systemd: |
| 114 | units: |
| 115 | - name: var-mnt-longhorn.mount |
| 116 | enabled: true |
| 117 | contents: | |
| 118 | [Unit] |
| 119 | Before=local-fs.target |
| 120 | [Mount] |
| 121 | Where=/var/mnt/longhorn |
| 122 | What=/dev/disk/by-label/longhorn |
| 123 | Options=rw,relatime,discard |
| 124 | [Install] |
| 125 | WantedBy=local-fs.target |
| 126 | ``` |
| 127 | |
| 128 | #### Label and Annotate Nodes |
| 129 | |
| 130 | Label and annotate storage nodes like this: |
| 131 | |
| 132 | ```bash |
| 133 | oc get nodes --no-headers | awk '{print $1}' |
| 134 | |
| 135 | export NODE="worker-0" |
| 136 | oc annotate node ${NODE} --overwrite node.longhorn.io/default-disks-config='[{"path":"/var/mnt/longhorn","allowScheduling":true}]' |
| 137 | oc label node ${NODE} node.longhorn.io/create-default-disk=config |
| 138 | ``` |
| 139 | |
| 140 | ## Example values.yaml |
| 141 | |
| 142 | Minimum Adjustments Required |
| 143 | |
| 144 | ```yaml |
| 145 | openshift: |
| 146 | oauthProxy: |
| 147 | repository: quay.io/openshift/origin-oauth-proxy |
| 148 | tag: 4.15 # Use Your OCP/OKD 4.X Version, Current Stable is 4.15 |
| 149 | |
| 150 | # defaultSettings: # Preparing nodes (Optional) |
| 151 | # createDefaultDiskLabeledNodes: true |
| 152 | |
| 153 | openshift: |
| 154 | enabled: true |
| 155 | ui: |
| 156 | route: "longhorn-ui" |
| 157 | port: 443 |
| 158 | proxy: 8443 |
| 159 | ``` |
| 160 | |
| 161 | ## Installation |
| 162 | |
| 163 | ```bash |
| 164 | # helm template ./chart/ --namespace longhorn-system --values ./chart/values.yaml --no-hooks > longhorn.yaml # Local Testing |
| 165 | helm template longhorn --namespace longhorn-system --values values.yaml --no-hooks > longhorn.yaml |
| 166 | oc create namespace longhorn-system -o yaml --dry-run=client | oc apply -f - |
| 167 | oc apply -f longhorn.yaml -n longhorn-system |
| 168 | ``` |
| 169 | |
| 170 | ## Refs |
| 171 | |
| 172 | - <https://docs.openshift.com/container-platform/4.11/storage/persistent_storage/persistent-storage-iscsi.html> |
| 173 | - <https://docs.okd.io/4.11/storage/persistent_storage/persistent-storage-iscsi.html> |
| 174 | - okd 4.5: <https://github.com/longhorn/longhorn/issues/1831#issuecomment-702690613> |
| 175 | - okd 4.6: <https://github.com/longhorn/longhorn/issues/1831#issuecomment-765884631> |
| 176 | - oauth-proxy: <https://github.com/openshift/oauth-proxy/blob/master/contrib/sidecar.yaml> |
| 177 | - <https://github.com/longhorn/longhorn/issues/1831> |