1.vim ex280-quota.yaml编辑定额资源文件。cat ex280-quota.yaml 查看定额资源文件。
[[email protected] test]$ vim ex280-quota.yaml
[[email protected] test]$ cat ex280-quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: ex280-quota
spec:
hard:
memory: "1Gi"
cpu: "2m"
replicationcontrollers: 3
pods: 3
services: 6
2.vim ex280-limits.yaml 编写限额资源文件。 cat ex280-limits.yaml查看限额资源文件。
[[email protected] test]$ vim ex280-limits.yaml
[[email protected] test]$ cat ex280-limits.yaml
apiVersion: v1
kind: LimitRange
metadata:
name: ex280-limits
spec:
limits:
- type: "Pod"
max:
cpu: "500m"
memory: "300Mi"
min:
cpu: "10m"
memory: "5Mi"
- type: "Container"
max:
cpu: "500m"
memory: "300Mi"
min:
cpu: "10m"
memory: "5Mi"
default:
cpu: "100m"
memory: "100Mi"
3.oc project squid选择项目。oc apply -f ex280-quota.yaml 声明定额资源。oc apply -f ex280-limits.yaml声明限额资源。
[[email protected] test]$ oc project squid
Now using project "squid" on server "https://master.lab.example.com:8443".
[[email protected] test]$ oc apply -f ex280-quota.yaml
resourcequota "ex280-quota" created
[[email protected] test]$ oc apply -f ex280-limits.yaml
limitrange "ex280-limits" created
4.oc get quota -o wide获取定额资源。oc get limitrange -o wide获取限额资源。oc describe quota ex280-quota查看定额资源详细信息。oc describe limitrange ex280-limit查看限额资源详细信息。
[[email protected] test]$ oc get quota -o wide
NAME AGE
ex280-quota 1m
[[email protected] test]$ oc get limitrange -o wide
NAME AGE
ex280-limits 50s
[[email protected] test]$ oc describe quota ex280-quota
Name: ex280-quota
Namespace: squid
Resource Used Hard
-------- ---- ----
cpu 0 2m
memory 0 1Gi
pods 0 3
replicationcontrollers 0 3
services 0 6
[[email protected] test]$ oc describe limitrange ex280-limit
Name: ex280-limits
Namespace: squid
Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio
---- -------- --- --- --------------- ------------- -----------------------
Pod cpu 10m 500m - - -
Pod memory 5Mi 300Mi - - -
Container cpu 10m 500m 100m 100m -
Container memory 5Mi 300Mi 100Mi 100Mi -