use*_*626 2 kubernetes persistent-volume-claims
20Mi storage limits
我使用和创建了持久卷声明,17 Mi storage requests
但我可以在文件夹中上传 50 Mi 的文件hostPath
。但我想要的是限制文件夹内容的大小。如果文件夹中的内容超过 20Mi,那么 Kubernetes 应该说它不允许新文件。
持久量:
apiVersion: v1
kind: PersistentVolume
metadata:
name: example-pv
namespace: limit-range
spec:
capacity:
storage: 10Gi
accessModes:
- ReadWriteOnce
persistentVolumeReclaimPolicy: Retain
storageClassName: local-storage
hostPath:
path: /home/me/kubernetes/web
type: DirectoryOrCreate
Run Code Online (Sandbox Code Playgroud)
持久卷声明:
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: pvc
namespace: limit-range
spec:
storageClassName: local-storage
accessModes:
- ReadWriteOnce
resources:
limits:
storage: 20Mi
requests:
storage: 17Mi
Run Code Online (Sandbox Code Playgroud)
部署:
apiVersion: apps/v1
kind: Deployment
metadata:
name: upload-preview-2
namespace: limit-range
spec:
selector:
matchLabels:
app: upload-preview-2
template:
metadata:
labels:
app: upload-preview-2
spec:
containers:
- image: upload-preview:latest
imagePullPolicy: Never
name: web
ports:
- containerPort: 80
volumeMounts:
- mountPath: /var/www/html/web
name: localpath
subPath: dev
volumes:
- name: localpath
persistentVolumeClaim:
claimName: pvc
Run Code Online (Sandbox Code Playgroud)
有了这个配置,它并没有给我我所期望的。所以我尝试了Limit range
,Quota
但仍然没有出现预期的行为。
极限范围:
apiVersion: v1 kind: LimitRange metadata: name: storagelimits namespace: limit-range spec: limits:
- type: PersistentVolumeClaim
max:
storage: 18Mi
min:
storage: 10Mi
Run Code Online (Sandbox Code Playgroud)
配额:
apiVersion: v1
kind: ResourceQuota
metadata:
name: storagequota
namespace: limit-range
spec:
hard:
persistentvolumeclaims: "5"
requests.storage: "18Mi"
Run Code Online (Sandbox Code Playgroud)
我尝试了一下kubectl describe quota -n limit-range
,结果是:
Name: storagequota
Namespace: limit-range
Resource Used Hard
-------- ---- ----
persistentvolumeclaims 1 5
requests.storage 17Mi 18Mi
Run Code Online (Sandbox Code Playgroud)
我的想法是它可能不起作用,因为我正在使用hostPath
.
归档时间: |
|
查看次数: |
3879 次 |
最近记录: |