模拟题目:

设置配置环境:

[candidate@node-1] $ kubectl config use-context k8s

Task

qutt 命名空间,创建一个名为 myquota 的 Quota,该资源 Quota 具有 1 个CPU, 1G 内存和 2个 pod的硬限制。

参考:

https://kubernetes.io/zh-cn/docs/concepts/policy/resource-quotas/#viewing-and-setting-quotas

apiVersion: v1
kind: ResourceQuota
metadata:
  name: pods-medium
spec:
  hard:
    cpu: "10"
    memory: 20Gi
    pods: "10"

解答:

切换环境

kubectl config use-context k8s

创建quota

vim quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
  name: myquota 
  namespace: qutt
spec:
  hard:
    cpu: "1"
    memory: 2Gi
    pods: "2"

应用

kubectl apply -f quota.yaml

检查

kubectl -n qutt get quota

file