k8s中的cephfs扩容
cephf-provisoner源码查看
pv := &v1.PersistentVolume{
ObjectMeta: metav1.ObjectMeta{
Name: options.PVName,
Annotations: map[string]string{
provisionerIDAnn: p.identity,
cephShareAnn: share,
},
},
Spec: v1.PersistentVolumeSpec{
PersistentVolumeReclaimPolicy: options.PersistentVolumeReclaimPolicy,
AccessModes: options.PVC.Spec.AccessModes,
MountOptions: options.MountOptions,
Capacity: v1.ResourceList{
// Quotas are supported by the userspace client(ceph-fuse, libcephfs), or kernel client >= 4.17 but only on mimic clusters.
// In other cases capacity is meaningless here.
// If quota is enabled, provisioner will set ceph.quota.max_bytes on volume path.
v1.ResourceName(v1.ResourceStorage): options.PVC.Spec.Resources.Requests[v1.ResourceName(v1.ResourceStorage)],
},
PersistentVolumeSource: v1.PersistentVolumeSource{
CephFS: &v1.CephFSPersistentVolumeSource{
Monitors: mon,
Path: res.Path[strings.Index(res.Path, "/"):],
SecretRef: &v1.SecretReference{
Name: secretName,
Namespace: nameSpace,
},
User: user,
},
},
},
}
k8s中的cephfs通过设置pv的属性来达到设置用户的配额的目的。即限制用户的挂载目录大小。具体的参数为ceph.quota.max_bytes
cephfs中的配额操作
cephfs中的配额设置
- ceph.quota.max_files 限制目录的文件数
- ceph.quota.max_bytes 限制目录大小
设置配额
setfattr -n ceph.quota.max_bytes -v 100000000 /some/dir # 100 MB
setfattr -n ceph.quota.max_files -v 10000 /some/dir # 10,000 files
查看配额,如果是0的话,配额未设置
getfattr -n ceph.quota.max_bytes /some/dir
getfattr -n ceph.quota.max_files /some/dir
移除配额
setfattr -n ceph.quota.max_bytes -v 0 /some/dir
setfattr -n ceph.quota.max_files -v 0 /some/dir
扩容
通过上述配置,可以发现,cephfs的配额基本通过设置cephfs相关配额属性来实现。所以,我们只需要重新修改下pod挂载目录的配额即可。
setfattr -n ceph.quota.max_bytes -v 1000000000 /some/dir