Skip to content

Commit 7d0cd44

Browse files
authored
docs(enable-xfs-quota) - documentation for applying xfs quota (#91)
* added enable-xfs.md * changed name * added loopback device documentation
1 parent e8a9e9a commit 7d0cd44

File tree

2 files changed

+173
-0
lines changed

2 files changed

+173
-0
lines changed
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
# Create XFS filesystem at the basepath as loopback device (if filesystem is not XFS)
2+
3+
Create a 32Mb disk file which will be formatted as xfs filesystem, mounted as loopback device and exposed as the directory `/var/openebs/local`
4+
5+
1. make sure library for managing xfs-fs is installed
6+
```console
7+
sudo apt update
8+
sudo apt-get install -y xfsprogs
9+
```
10+
11+
2. make directory where mount will occur :-
12+
```console
13+
sudo mkdir -p /var/openebs/local
14+
cd /var/openebs
15+
```
16+
17+
3. create sparse file of max size 32Mb using seek of max size 32Mb
18+
```console
19+
sudo dd if=/dev/zero of=xfs.32M bs=1 count=0 seek=32M
20+
```
21+
22+
4. format the sparse file in xfs format
23+
```console
24+
sudo mkfs -t xfs -q xfs.32M
25+
```
26+
27+
5. mount it as loopback device with project quota enabled
28+
```console
29+
sudo mount -o loop,rw xfs.32M -o pquota /var/openebs/local
30+
```
Lines changed: 143 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,143 @@
1+
# OpenEBS LocalPV Hostpath Enable XFS Quota
2+
3+
### Prerequisites
4+
5+
1. A Kubernetes cluster with Kubernetes v1.16 or above is required
6+
2. All the nodes must have xfs utils installed
7+
3. The base path used by the provisioner should have XFS filesystem
8+
4. The base path used by the provisioner should be mounted with XFS project quotas enabled
9+
10+
### Check Basepath
11+
Verify that filesystem is xfs
12+
```console
13+
stat -f -c %T /var/openebs/local
14+
```
15+
Filesystem of Basepath will be shown
16+
```console
17+
xfs
18+
```
19+
20+
Verify that project quotas are enabled
21+
```console
22+
xfs_quota -x -c state | grep 'Project quota state on /var/openebs/local' -A 2
23+
```
24+
Both Accounting and Enforcement should be ON
25+
```console
26+
Project quota state on /var/openebs/local (/dev/loop16)
27+
Accounting: ON
28+
Enforcement: ON
29+
```
30+
31+
If project quotas are not enabled :-
32+
33+
To set project quota on `/var/openebs/local`, enable project quota on `/var` filesystem,
34+
edit the `/etc/fstab` file, add `prjquota` after `default` keyword for `/var` file system
35+
```console
36+
$ vi /etc/fstab
37+
……………………………….
38+
/dev/mapper/Vol-var /var xfs defaults,prjquota 0 0
39+
…………………………………
40+
```
41+
Then reboot the system
42+
43+
44+
### Installing
45+
Install the OpenEBS Dynamic LocalPV Provisioner using the following command:
46+
```console
47+
kubectl apply -f https://openebs.github.io/charts/openebs-operator-lite.yaml
48+
```
49+
Verify that pods in openebs namespace are running
50+
```console
51+
$ kubectl get pods -n openebs
52+
53+
NAME READY STATUS RESTARTS AGE
54+
openebs-localpv-provisioner-6ddbd95d4d-htp7g 1/1 Running 0 7m12s
55+
openebs-ndm-operator-849d89cb87-djct8 1/1 Running 0 7m12s
56+
openebs-ndm-zd8lt 1/1 Running 0 7m12s
57+
```
58+
59+
### Deployment
60+
61+
#### 1. Create a Storage Class
62+
```yaml
63+
apiVersion: storage.k8s.io/v1
64+
kind: StorageClass
65+
metadata:
66+
name: openebs-hostpath-xfs
67+
annotations:
68+
openebs.io/cas-type: local
69+
cas.openebs.io/config: |
70+
- name: StorageType
71+
value: "hostpath"
72+
- name: BasePath
73+
value: "/var/openebs/local/"
74+
provisioner: openebs.io/local
75+
volumeBindingMode: WaitForFirstConsumer
76+
reclaimPolicy: Delete
77+
parameters:
78+
enableXfsQuota: 'true'
79+
softLimitGrace: 20%
80+
hardLimitGrace: 40%
81+
```
82+
`softLimitGrace` and `hardLimitGrace` with PV Storage Request will decide the soft limit and hard limit to be set.
83+
The size of a limit will be => size of PV Storage request * ( 1 + LimitGrace% )
84+
Anyone of hard limit or soft limit can also be used
85+
[Click here](https://man7.org/linux/man-pages/man8/xfs_quota.8.html#QUOTA_OVERVIEW) for detailed instructions about soft and hard limits.
86+
87+
#### 2. Create a PVC with storage class
88+
```yaml
89+
kind: PersistentVolumeClaim
90+
apiVersion: v1
91+
metadata:
92+
name: local-hostpath-pvc
93+
spec:
94+
storageClassName: openebs-hostpath-xfs
95+
accessModes:
96+
- ReadWriteOnce
97+
resources:
98+
requests:
99+
storage: 5G
100+
```
101+
The PVC will be in 'Pending' state until the volume is mounted.
102+
```console
103+
$ kubectl get pvc
104+
105+
NAME STATUS VOLUME CAPACITY ACCESS MODES STORAGECLASS AGE
106+
local-hostpath-pvc Pending openebs-hostpath-xfs 21s
107+
```
108+
109+
#### 3. Mount the Volume
110+
Mount the volume to the application pod container. The PVC status will change to 'Bound' when the volume is mounted to a container and quota is applied. A sample BusyBox Pod template is given below.
111+
```yaml
112+
apiVersion: v1
113+
kind: Pod
114+
metadata:
115+
name: busybox
116+
spec:
117+
volumes:
118+
- name: local-storage
119+
persistentVolumeClaim:
120+
claimName: local-hostpath-pvc
121+
containers:
122+
- name: busybox
123+
image: busybox
124+
command:
125+
- sh
126+
- -c
127+
- 'while true; do echo "`date` [`hostname`] Hello from OpenEBS Local PV." >> /mnt/store/greet.txt; sleep $(($RANDOM % 5 + 300)); done'
128+
volumeMounts:
129+
- mountPath: /mnt/store
130+
name: local-storage
131+
```
132+
Verify that quota is applied successfully
133+
```console
134+
master@node$ sudo xfs_quota -x -c 'report -h' /var/openebs/local/
135+
Project quota on /var/openebs/local (/dev/loop16)
136+
Blocks
137+
Project ID Used Soft Hard Warn/Grace
138+
---------- ---------------------------------
139+
#0 0 0 0 00 [------]
140+
#1 0 5.7G 6.7G 00 [------]
141+
```
142+
#### Limitation
143+
* Resize of quota is not supported

0 commit comments

Comments
 (0)