准入练习
ResourceQuota
限制 configmap
cat quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: object-counts
namespace: default
spec:
hard:
configmaps: "1"
应用
k apply -f quota.yaml
k get resourcequota
output
NAME AGE REQUEST LIMIT
object-counts 5s configmaps: 1/1
configmap 资源已经用完
验证
k get cm
output
NAME DATA AGE
kube-root-ca.crt 1 10d
创建 configmap
k create configmap aaa --from-file quota.yaml
output
error: failed to create configmap: configmaps "aaa" is forbidden: exceeded quota: object-counts, requested: configmaps=1, used: configmaps=1, limited: configmaps=1
删除限制
k delete resourcequota object-counts
resourcequota "object-counts" deleted
k create configmap aaa --from-file quota.yaml
configmap/aaa created
k get cm
NAME DATA AGE
aaa 1 32s
kube-root-ca.crt 1 10d
创建成功