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 [------]
相关推荐
衍余未了16 分钟前
k8s除了主server服务器可正常使用kubectl命令,其他节点不能使用原因,以及如何在其他k8s节点正常使用kubectl命令??
云原生·容器·kubernetes
Clownseven26 分钟前
Mattermost教程:用Docker搭建自己的开源Slack替代品 (团队聊天)
docker·容器·开源
❀͜͡傀儡师31 分钟前
Docker部署Drawnix开源白板工具
docker·容器·开源·drawnix
❀͜͡傀儡师32 分钟前
Docker部署Lunalytics开源监控工具
docker·容器·开源·lunalytics
To_再飞行33 分钟前
K8s 存储配置资源
linux·云原生·容器·kubernetes
To_再飞行2 小时前
K8s 调度管理
linux·云原生·kubernetes
milanyangbo3 小时前
“卧槽,系统又崩了!”——别慌,这也许是你看过最通俗易懂的分布式入门
分布式·后端·云原生·架构
大咖分享课3 小时前
系统越拆越乱?你可能误解了微服务的本质!
微服务·云原生·架构
2418ly4 小时前
docker常用命令
运维·docker·容器