# Setting up persistant storage using OpenEBS

## Install iSCSI on all nodes

Refer: [https://docs.openebs.io/docs/next/prerequisites.html](https://docs.openebs.io/docs/next/prerequisites.html)

### Install iSCSI tools if not installed

```shell
sudo apt-get update
sudo apt-get install open-iscsi
sudo systemctl enable --now iscsid
```

### Check if iSCSI is running

```shell
sudo systemctl status iscsid
```

[![image-1621427648458.png](https://book-stack.rapidoreach.com/uploads/images/gallery/2021-05/scaled-1680-/VPCA9lGBcRYWewp8-image-1621427648458.png)](https://book-stack.rapidoreach.com/uploads/images/gallery/2021-05/VPCA9lGBcRYWewp8-image-1621427648458.png)

## Make sure you have admin context

```shell
kubectl config use-context kubernetes-admin@kubernetes
```

## Remove taint from master node

We need to use master node as a storage node where all database files and persistant volumes will be stored. Remove taint from master node so that master node will be available to schedule pods

```
kubectl taint node <masternode_name> node-role.kubernetes.io/master:NoSchedule-
```

## Install using kubectl

Download file [https://openebs.github.io/charts/openebs-operator.yaml](https://openebs.github.io/charts/openebs-operator.yaml)

to install OpenEBS to use volumes from master node we need to label master node with appropriate label

Use following command to label master node

```shell
kubectl label nodes <node-name> node=openebs
```

Next, in the downloaded openebs-operator.yaml, find the PodSpec for `openebs-provisioner`, `maya-apiserver`, `openebs-snapshot-operator`, `openebs-admission-server` and `openebs-ndm` pods and add the following key-value pair under `nodeSelector` field

nodeSelector field will be available in pod &gt; specs &gt; template &gt; specs &gt; nodeSelector

```YAML
nodeSelector:
  node: openebs
```

Install OpenEBS with updated command

```shell
kubectl apply -f openebs-operator.yml
```

## Check if OpenEBS has been installed

```shell
kubectl get pods -n openebs -o wide
```

Output should show running pods

[![image-1621437399553.png](https://book-stack.rapidoreach.com/uploads/images/gallery/2021-05/scaled-1680-/A7A7KpLklgQWpltI-image-1621437399553.png)](https://book-stack.rapidoreach.com/uploads/images/gallery/2021-05/A7A7KpLklgQWpltI-image-1621437399553.png)