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 [------]
相关推荐
热爱Liunx的丘丘人6 小时前
1、什么是K8s
云原生·容器·kubernetes
帷幕落秋8 小时前
Docker的两种安装
运维·docker·容器
fengkai45458 小时前
十二、Redis -2
运维·数据库·redis·容器
DolitD10 小时前
3D应用多实例并发中的GPU隔离技术路径分析
容器·gru·接口隔离原则
姜鱼问生11 小时前
docker exec 排查容器问题:从日志到进程
运维·网络·数据库·docker·容器
小匠石钧知14 小时前
07_在k8s集群中安装ingress-nginx
nginx·容器·kubernetes·ingress
零基础12314 小时前
Docker 部署实战:从入门到精通
docker·容器
承渊政道15 小时前
自建服务越来越多怎么管理?Docker部署Flare,搭一个自己的数字入口
运维·docker·容器·内网穿透·cpolar·nas·flare
芷栀夏16 小时前
极空间部署Photopea:Docker运行、网页修图与多设备使用
运维·docker·容器
openFuyao1 天前
新增Agent沙箱调度能力!openFuyao v26.09社区发行版上线,AI原生基础设施能力进一步升级
云原生·ai-native·ai推理·openfuyao·多样化算力集群软件