Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/ksingh7/odf-nano

ODF-Nano lets you deploy OpenShift Data Foundation on your Laptop (CRC)
https://github.com/ksingh7/odf-nano

crc odf

Last synced: about 2 months ago
JSON representation

ODF-Nano lets you deploy OpenShift Data Foundation on your Laptop (CRC)

Awesome Lists containing this project

README

        

![](assets/odf-nano-logo-white.png)
# Whats the need ?

- Developers love OpenShift :heart:
- Developers need local OpenShift environment (Solution : [CRC (CodeReady Containers)](https://developers.redhat.com/products/codeready-containers/overview) ) :computer:
- Developers build Applications, that need Block/File/Object storage :hammer:
- ODF provides Block/File/Object storage to OpenShift :ok_hand:
- ODF Nano deploys ODF on CRC :raised_hands: :clap:

# Introducing ODF-Nano
tldr; Watch introduction & Demo Video [here](https://www.youtube.com/watch?v=mae0tiLkQag)

`ODF-Nano` lets you deploy [OpenShift Data Foundation](https://www.redhat.com/en/technologies/cloud-computing/openshift-data-foundation) on your Laptop (CRC).
- For dev/test experimentation developers ofter need persistent storage with CRC.
- Currently CRC lacks clean & simple persistent storage solution, `ODF-Nano` solves this problem for CRC.
- Devs can now develop/test their apps locally using `CRC+ODF-Nano`. Once the app is ready, it could be deployed in production `OCP+ODF` without any change
# Setup

## Prerequisites
### Host OS
- RHEL 8,
- Fedora 34 (tested) [ Feel free to test with other releases ]
- Ubuntu 20.04 (tested) [ Feel free to test with other releases ]
- MacOS ( Need more tests )

### CRC / OC Binaries
- Download CRC and OC binaries from [cloud.redhat.com]((https://cloud.redhat.com/openshift/create/local)
- Create CRC directlry `mkdir ~/.crc`
- Also get CRC pull secret from [cloud.redhat.com]((https://cloud.redhat.com/openshift/create/local) and save it as `~/.crc/pull-secret.txt`
## Step -1 :: Deploy CRC - Linux
### Watch Demo Video [here](https://www.youtube.com/watch?v=mae0tiLkQag)

Note : If you have already deployed CRC using [OpenSpot](https://github.com/ksingh7/openspot) project, you can skip step-1 and move directly to [step-2](https://github.com/ksingh7/odf-nano#step--2--deploy-odf-nano-on-crc)
```
mkdir ~/.crc
cd ~/.crc
# Get CRC pull secret from [cloud.redhat.com]((https://cloud.redhat.com/openshift/create/local) and save it as `~/.crc/pull-secret.txt`
crc config set consent-telemetry no
crc config set enable-cluster-monitoring true # Enable only if you have enough memory, needs ~4G extra
crc config set cpus 15 #Change as per your HW config
crc config set memory 60000 #Change as per your HW config
crc config set pull-secret-file ~/.crc/pull-secret.txt
crc config view
crc setup
alias crcssh='ssh -i ~/.crc/machines/crc/id_ecdsa core@"$(crc ip)"'
crc start
crcssh uptime
crc console --credentials > crc-creds.txt
```
- Access https://console-openshift-console.apps-crc.testing from client machine

## Step -2 :: Deploy ODF-Nano on CRC - Linux
### Prerequisites
- SSH into the host machine running CRC VM
- Create a few raw devices that `ODF-Nano` will use
```
## Don't worry this is thin provisioned
sudo -S qemu-img create -f raw ~/.crc/vdb 100G
sudo -S qemu-img create -f raw ~/.crc/vdc 100G
```

- Attach these devices to CRC VM
```
crc stop
sudo virsh list --all
sudo virsh dumpxml crc > ~/crc.xml
vim ~/crc.xml
```
- Add the following section to `crc.xml`
- Make sure to set the correct disk path
```
















```
- Apply XML file and start CRC
```
sed -i "s|~|$HOME|g" ~/crc.xml
sudo virsh define ~/crc.xml
crc start
```
- List devices to verify
```
crcssh lsblk
```

## Step -1 :: Deploy CRC - MACOS
### Watch Demo Video [here](https://www.youtube.com/watch?v=mae0tiLkQag)

```
mkdir ~/.crc
cd ~/.crc
# Get CRC pull secret from [cloud.redhat.com]((https://cloud.redhat.com/openshift/create/local) and save it as `~/.crc/pull-secret.txt`
crc config set consent-telemetry no
crc config set enable-cluster-monitoring true # Enable only if you have enough memory, needs ~4G extra
crc config set cpus 9 #Change as per your HW config
crc config set memory 32768 #Change as per your HW config
crc config set disk-size 250 #Don't worry this is thin provisioned
crc config set pull-secret-file ~/.crc/pull-secret.txt
crc config view
crc setup
alias crcssh='ssh -p 2222 -i ~/.crc/machines/crc/id_ecdsa core@"$(crc ip)"'
crc start
crcssh uptime
crc console --credentials > crc-creds.txt
```
- Access https://console-openshift-console.apps-crc.testing from client machine

## Step -2 :: Deploy ODF-Nano on CRC - MACOS
### Prerequisites
- SSH into the host machine running CRC VM
- Create a few loopback devices that `ODF-Nano` will use
```
## Don't worry this is thin provisioned
sudo -i
mkdir -p /var/lib/storage
truncate --size 220G /var/lib/storage/disk1
losetup -P /dev/loop1 /var/lib/storage/disk1
pvcreate /dev/loop1
vgcreate odf /dev/loop1
lvcreate -n disk1 -L 105G odf
lvcreate -n disk2 -L 105G odf

lsblk

cat << EOF > /etc/systemd/system/lvm-odf-losetup.service
[Unit]
Description=LVM ODF loopback device setup
DefaultDependencies=no
Conflicts=umount.target
Requires=lvm2-lvmetad.service systemd-udev-settle.service
Before=local-fs.target umount.target
After=lvm2-lvmetad.service systemd-udev-settle.service
[Service]
Type=oneshot
ExecStart=/sbin/losetup -P /dev/loop1 /var/lib/storage/disk1
ExecStop=/sbin/losetup -d /dev/loop1
RemainAfterExit=yes
[Install]
WantedBy=local-fs-pre.target
EOF

systemctl enable lvm-odf-losetup
```

### Deploy ODF-Nano on CRC

- Login to CRC using `kubeadmin`
`oc login -u kubeadmin -p https://api.crc.testing:6443`

- Get `odf-nano`
```
git clone https://github.com/ksingh7/odf-nano.git
cd odf-nano
```
- Install `odf-nano` - LINUX
```
sh deploy_odf.sh
```
- Install `odf-nano` - MacOS
```
sh deploy_odf_macos.sh
```

- Sample output
```
Setting up environment for ODF - this will take a few minutes
subscription.operators.coreos.com/ocs-subscription created
Waiting for operators to be ready
No resources found in openshift-storage namespace.
.No resources found in openshift-storage namespace.
...
.No resources found in openshift-storage namespace.
...............................
Operators are ready now
Finished up preparing the local storage
ODF is installing now, please be patient
ocsinitialization.ocs.openshift.io/ocsinit patched
pod/rook-ceph-tools-7d95854fb8-b78s2 condition met
ODF is installed now
```
- Verify ODF setup
```
oc get sc
```
- You now have File/Block/Object Persistent Storage Classes from ODF. Deploy and Test your app locally, like you do in production (OCP & ODF)

![ODF Storage Classes](assets/odf-sc.png)
# Miscelleanous

## ODF-Nano Resource Footprint & Components
- Resource Footprint

| CPU | Memory |
| --------------- | --------------- |
| 3 vCPU | 2.5G |

- ODF Components

| Component | Count |
| --------------- | --------------- |
| MON | 1 |
| MGR | 1 |
| OSD | 2 |
| MDS | 2 |
| RGW | 1 |
| Ceph-Tools | 1 |
| ocs-metrics-exporter | 1 |
| ocs-operator | 1 |
| noobaa-operator | 1 |

** Reducing MDS count to 1 is WIP **

## Access CRC from a remote client
By default CRC cluster is reachable from localhost. Inorder to access a CRC cluster remotely, we need to add a proxy layer.
This setup is useful, when you want to deploy CRC on a remote machine (Home server or a Cloud bare metal), there has to be a way for you to acces CRC cluster remotely. This procedure help you access your CRC remotely.

- Execute on the Host running CRC VM
```
SERVER_IP=0.0.0.0
CRC_IP=$(crc ip)
sudo cp /etc/haproxy/haproxy.cfg{,.bak}
sudo semanage port -a -t http_port_t -p tcp 6443
sudo tee /etc/haproxy/haproxy.cfg &>/dev/null <