背景
使用local-path-provisioner来供应local pv,但是local-path-provisioner仓库内没有提供local pv的配额限制方法
所以需要修改他的configmap中的配置
修改
yourimage内需要带xfs_quota命令
yourpath为local pv在host侧的目录
yourmountpoint为local pv在host侧目录对应的挂载点
apiVersion: v1
data:
config.json: |-
{
"nodePathMap":[
{
"node":"DEFAULT_PATH_FOR_NON_LISTED_NODES",
"paths":["/yourpath"]
}
]
}
helperPod.yaml: |-
apiVersion: v1
kind: Pod
metadata:
name: helper-pod
spec:
priorityClassName: system-node-critical
tolerations:
- key: node.kubernetes.io/disk-pressure
operator: Exists
effect: NoSchedule
containers:
- name: helper-pod
securityContext:
privileged: true
image: yourimage
imagePullPolicy: IfNotPresent
volumeMounts:
- name: projects
mountPath: /etc/projects
- name: projid
mountPath: /etc/projid
- name: dev
mountPath: /dev
- name: yourmountpoint
mountPath: /yourmountpoint
volumes:
- hostPath:
path: /etc/projects
type: FileOrCreate
name: projects
- hostPath:
path: /etc/projid
type: FileOrCreate
name: projid
- hostPath:
path: /dev
type: Directory
name: dev
- hostPath:
path: /yourmountpoint
type: Directory
name: yourmountpoint
setup: |-
#!/bin/sh
set -e
xfsPath="/yourmountpoint"
pvcName=VOL_DIR")
mkdir -p "{xfsPath}
if [ ${type} = 'xfs' ]; then echo "support xfs quota" exec 6>/tmp/local-path.lock flock -nx 6 project=cat /etc/projects | tail -n 1id=echo {project} ]; then
id=1
else
id={id}:
{pvcName}:
{pvcName}"
xfs_quota -x -c "limit -p bsoft={VOL_SIZE_BYTES}
{xfsPath}
xfs_quota -x -c "report -pbih" (basename "
{xfsPath}`
if [ {pvcName}"
VOL_DIR"
if [ (sed "/
(sed "/
{xfsPath}
fi
kind: ConfigMap
metadata:
name: local-path-config
namespace: local-path-storage









网友评论