Skip to content

Commit

Permalink
docs(volume): add raw block volume docs with a usecase (#149)
Browse files Browse the repository at this point in the history
Signed-off-by: prateekpandey14 <[email protected]>
  • Loading branch information
prateekpandey14 authored Aug 6, 2020
1 parent d9023cb commit 0b70958
Show file tree
Hide file tree
Showing 2 changed files with 116 additions and 0 deletions.
1 change: 1 addition & 0 deletions docs/tutorial/intro.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ On a high level, this tutorial covers following:
2. This [link](./volumes/snapshot.md) explains the volume snapshot related operations.
3. This [link](./volumes/resize.md) explains the volume resize related operations.
4. This [link](./volumes/migration.md) explains the volume migration related operations across k8s nodes.
5. This [link](./volumes/block_volume.md) explains how to use cstor raw block volume.
115 changes: 115 additions & 0 deletions docs/tutorial/volumes/block_volume.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
# CStor CSI RAW Block Volume:

When using a raw block volume in your Pods, you must specify a VolumeDevice attribute
in the Container section of the PodSpec rather than a VolumeMount. VolumeDevices
have devicePaths instead of mountPaths, and inside the container, applications
will see a device at that path instead of a mounted file system.

A block volume will appear as a block device inside the container,and allows
low-level access to the storage without intermediate layers, as with file-system
volumes.There are advantages of raw disk partitions for example:

- Block devices that are actually SCSI disks support sending SCSI commands to the
device using Linux ioctls.
- Faster I/O without UNIX file system overhead, and more synchronous I/O without
UNIX file system buffering etc.

### How to use block volume

There is a number of use cases where a raw block device will be useful. For example,
A user can use a raw block device for database applications such as MySQL to read
data from and write the results to a disk that has a formatted filesystem to be
displayed via the nginx web server.

The following sections describe some sample volume specifications and steps to dynamically
provision a raw block volume and attach it to an application pod.

### Creating a new raw block PVC
1. Raw Block volume:

```yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: block-claim
spec:
volumeMode: Block
storageClassName: cstor-disk-stripe
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi

```

2. Filesystem based volume:

```yaml
kind: PersistentVolumeClaim
apiVersion: v1
metadata:
name: fs-claim
spec:
storageClassName: cstor-disk-stripe
accessModes:
- ReadWriteOnce
resources:
requests:
storage: 5Gi
```
### Using a raw Block PVC in POD
Here, the user creates an application pod/deployment, having 2 containers consume both block &
filesystem volumes. We have to choose devicePath for the block device inside the
Mysql container rather than the mountPath for the file system. Nginx container
we have mounted the filesystem based volume.
```yaml
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
run: mysql
name: mysql
spec:
replicas: 1
selector:
matchLabels:
run: mysql
strategy: {}
template:
metadata:
labels:
run: mysql
spec:
containers:
- image: mysql
imagePullPolicy: IfNotPresent
name: mysql
volumeDevices:
- name: my-db-data
devicePath: /dev/block
env:
- name: MYSQL_ROOT_PASSWORD
value: test
- image: nginx
imagePullPolicy: IfNotPresent
name: nginx
ports:
- containerPort: 80
volumeMounts:
- name: my-nginx-data
mountPath: /usr/share/nginx/html
readOnly: false
volumes:
- name: my-db-data
persistentVolumeClaim:
claimName: block-claim
- name: my-nginx-data
persistentVolumeClaim:
claimName: fs-claim
```

0 comments on commit 0b70958

Please sign in to comment.