k8s使用自建nfs做持久化无法控制磁盘使用大小问题处理

如题,创建的pvc并无法控制用户实际使用多少nfs存储,使用xfs_quota来对用户nfs目录做磁盘配额管理

1、需使用xfs文件系统

2、/etc/fstab挂载中开启prjquota(项目配额)

具体操作如下

powershell 复制代码
xfs_quota  使用说明

/etc/fstab挂载磁盘
UUID="bd49b6be-1439-43f7-a6a6-dbec452dd236"     /testxfs        xfs     defaults,prjquota       0 0

#分配项目ID和目录  (一个路径一个ID)
echo "100:/testxfs/3G" >>/etc/projects
echo "3G:100" >>/etc/projid

xfs_quota -x -c 'project -s 3G' /testxfs
Setting up project 3G (path /testxfs/3G)...
Processed 1 (/etc/projects and cmdline) paths for project 3G with recursion depth infinite (-1).

#设置配额为3G
xfs_quota -x -c 'limit -p bhard=3g 3G' /testxfs


xfs_quota -x -c 'report -h' /testxfs
Project quota on /testxfs (/dev/mapper/nasvg-test)
                        Blocks
Project ID   Used   Soft   Hard Warn/Grace
---------- ---------------------------------
#0             7G      0      0  00 [------]
3G              0      0     3G  00 [------]

===========================================
[root@node01 3G]# dd if=/dev/zero of=3g_file bs=1G count=3
记录了3+0 的读入
记录了3+0 的写出
3221225472字节(3.2 GB,3.0 GiB)已复制,3.59724 s,895 MB/s
[root@node01 3G]# dd if=/dev/zero of=1g_file bs=1G count=3
dd: 打开'1g_file' 失败: 超出磁盘限额

[root@node01 3G]# df -h | grep xfs
/dev/mapper/nasvg-test                                                                               8.0G  3.1G  5.0G   39% /testxfs
[root@node01 3G]# pwd
/testxfs/3G

xfs_quota -x -c 'report -h' /testxfs
Project quota on /testxfs (/dev/mapper/nasvg-test)
                        Blocks
Project ID   Used   Soft   Hard Warn/Grace
---------- ---------------------------------
#0              0      0      0  00 [------]
3G             3G      0     3G  00 [------]
相关推荐
莫陌尛.7 小时前
Docker MySQL 删表卡死、执行超时(MDL锁阻塞)问题复盘与根治方案
mysql·docker·容器
天天喝旺仔7 小时前
Go 并发编程:Goroutine 与 Channel 实战
云原生·性能优化·架构·go
阿里云云原生12 小时前
记录一次排障范式的升级:当 AI 拥有“业务字典”,我们如何定义可信的数据查询?
云原生
正仪13 小时前
kubernetes中list-watch机制
云原生·容器·kubernetes
cui_hao_nan15 小时前
从零搭建 Kubernetes 集群:Ubuntu + kubeadm 完整实战
ubuntu·容器·kubernetes
fb_1234515 小时前
Docker入门-第3章-容器镜像深度解析
运维·docker·容器
IT摆渡者17 小时前
基于 Docker 部署 Nextcloud 私有云盘(外挂 Windows 共享)项目实践
运维·docker·容器
Jeromefromhk17 小时前
我把所有服务搬上 Kubernetes,又全部搬了回来
kubernetes·devops
墨香幽梦客18 小时前
Kubernetes+Istio实现CRM系统弹性伸缩:服务网格下的流量治理与熔断策略
容器·kubernetes·istio
新时代牛马18 小时前
单机 docker run 管不住了?从编排需求、期望状态到调度/自愈闭环讲透
运维·docker·容器