# Red Hat Local Storage operator

This section describes how to configure the Local Storage operator on Red Hat OpenShift Container Platform 4.

# Physical environment

Ensure a minimum of two unused disks (a minimum of 100 GB and 250 GB) are present on each worker node prior to implementing local persistent storage.

Note

Use the following command to find partition details.

$ lsblk

The output appears similar to what is shown.

 NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT

 loop0 7:0 0 250G 0 loop

 sda 8:0 0 150G 0 disk

 ├─sda1 8:1 0 1M 0 part

 ├─sda2 8:2 0 1G 0 part /boot

 └─sda3 8:3 0 149G 0 part /sysroot

 sdb 8:16 0 100G 0 disk

Note

sda is for OS volume. sdb is raw disk that is used to create local storage.

# Deploying local storage operator

  1. Login to the OpenShift Web Console.

  2. Navigate to Administration -> Namespaces and click Create Namespace.

  3. From the Create Namespace page, provide the following values and then click Create.

    • Name: local-storage

    • Select the No restrictions option for Default Network Policy.

  4. Navigate to Operators -> OperatorHub.

  5. From the list of operators, select Local Storage Operator.

  6. On the Local Storage Operator page, click Install.

  7. In the Create Operator Subscription page, provide the following details and click Subscribe.

    • Update Channel: 4.4

    • Approval Strategy: Select Manual or Automatic as per the installation environment requirement.

  8. Wait for the operator to be installed. The status of the installation can be monitored from the Installed Operators page.

  9. A filesystem is essential to create local file storage. Login to the installer VM, copy and update the following local-storage-filesystem.yaml file with values for the following parameters:

    • namespace: local-storage

    • values :Fully qualified domain name of the worker nodes

    • devicePaths: Partition of the worker nodes to be used to create the filesystem

    A sample local-storage-filesystem.yaml is as follows.

    apiVersion: "local.storage.openshift.io/v1"
    kind: "LocalVolume"
    metadata:
    name: "local-disks-fs1"
    namespace: "local-storage"
    spec:
    nodeSelector:
    nodeSelectorTerms:
    - matchExpressions:
    - key: kubernetes.io/hostname
    operator: In
    values:
    - worker1.ocp.twentynet.local
    - worker2.ocp.twentynet.local
    - worker3.ocp.twentynet.local
    storageClassDevices:
    - storageClassName: "local-sc"
    volumeMode: Filesystem
    fsType: xfs
    devicePaths:
    - /dev/sdb
    
  10. Execute the following command to create the local storage filesystem.

```bash
$ oc create –f local-storage-filesystem.yaml
```

The output is as follows.
    
``` bash
localvolume.local.storage.openshift.io/local-disks-fs created
```
  1. A disk is essential to create local block storage. Within the installer VM, copy and update the local-storage-block.yaml file with values for the following parameters.

    • namespace: local-storage

    • values: Fully qualified domain name of the worker nodes

    • devicePaths: Partition of the worker nodes to be used to create the block

    A sample local-storage-block.yaml file is as follows.

    apiVersion: "local.storage.openshift.io/v1"
    
    kind: "LocalVolume"
    
    metadata:
    
    name: "local-disks-fs1"
    
    namespace: "local-storage"
    
    spec:
    
    nodeSelector:
    
    nodeSelectorTerms:
    
    - matchExpressions:
    
    - key: kubernetes.io/hostname
    
    operator: In
    
    values:
    
    - worker1.ocp.twentynet.local
    
    - worker2.ocp.twentynet.local
    
    - worker3.ocp.twentynet.local
    
    storageClassDevices:
    
    - storageClassName: "local-sc"
    
    volumeMode: Filesystem
    
    fsType: xfs
    
    devicePaths:
    
    - /dev/sdb
    
  2. Execute the following command to create the resource.

    $ oc create –f local-storage-block.yaml
    

    The output is as follows.

    localvolume.local.storage.openshift.io/local-disks created
    
  3. Execute the following command to verify that all of the pods are up and running and that the Storage Class and PVs exist.

    $ oc get pod –n local-storage
    

    The output is as follows.

    NAME READY STATUS RESTARTS AGE
    
    local-disks-fs-local-diskmaker-6258p 1/1 Running 0 6d19h
    
    local-disks-fs-local-diskmaker-8rzgc 1/1 Running 0 6d19h
    
    local-disks-fs-local-diskmaker-c6vch 1/1 Running 0 6d19h
    
    local-disks-fs-local-provisioner-598f5 1/1 Running 0 6d19h
    
    local-disks-fs-local-provisioner-5g4vp 1/1 Running 0 6d19h
    
    local-disks-fs-local-provisioner-sxh5x 1/1 Running 0 6d19h
    
    local-disks-fs1-local-diskmaker-5p4s7 1/1 Running 0 4d17h
    
    local-disks-fs1-local-diskmaker-9jh6r 1/1 Running 0 4d17h
    
    local-disks-fs1-local-diskmaker-z62vd 1/1 Running 0 4d17h
    
    local-disks-fs1-local-provisioner-gjkn4 1/1 Running 0 4d17h
    
    local-disks-fs1-local-provisioner-kmdzt 1/1 Running 0 4d17h
    
    local-disks-fs1-local-provisioner-r28th 1/1 Running 0 4d17h
    
    local-disks-local-diskmaker-5wpr9 1/1 Running 0 6d19h
    
    local-disks-local-diskmaker-cg952 1/1 Running 0 6d19h
    
    local-disks-local-diskmaker-s7wvr 1/1 Running 0 6d19h
    
    local-disks-local-provisioner-dvg58 1/1 Running 0 6d19h
    
    local-disks-local-provisioner-lkl6p 1/1 Running 0 6d19h
    
    local-disks-local-provisioner-z4nj6 1/1 Running 0 6d19h
    
    local-storage-operator-688c6cf7fb-k95kq 1/1 Running 0 5d19h
    
    mongodb-1-9rrv4 1/1 Running 0 3d21h
    
    mongodb-1-deploy 0/1 Completed 0 3d21h
    
    mysql-ocs-fs-0 1/2 CrashLoopBackOff 252 21h
    
    mysql-ocs-fs-1 1/2 CrashLoopBackOff 253 21h
    

Note

For more information on the Red Hat Local Storage, refer to Red Hat documentation at https://docs.openshift.com/container-platform/4.4/storage/persistent_storage/persistent-storage-local.html (opens new window)