RHCA之路—EX280(7)
1. 题目
Configure quotas and limits for project shrimp so that:
The ResourceQuota resource is named ex280-quota
The amount of memory consumed across all containers may not exceed 1Gi
The total amount of CPU usage consumed across all containers may not exceed 2 Kubernetes compute units.
The maximum number of replication controllers does not exceed 3
The maximum number of pods does not exceed 3
The maximum number of service does not exceed 6
The LimitRange resource is named ex280-limits
The amount of memory consumed by a single pod is between 5Mi and 300Mi
The amount of memory consumed by a single container is between 5Mi amd 300Mi with a default request value of 100Mi.
The amount of cpu consumed by a single pod is between 10m and 500m
The amount of cpu consumed by a single container is between 10m and 500m with a default request value of 100m
2. 解题
2.1 切换项目
[root@master samples]# oc project shrimp
Now using project "shrimp" on server "https://master.lab.example.com".
[root@master samples]# mkdir ~/shrimp
[root@master samples]# cd ~/shrimp
[root@master shrimp]# oc projects
You have access to the following projects and can switch between them with 'oc project <projectname>':
default
ditto
farm
kube-public
kube-service-catalog
kube-system
logging
management-infra
openshift
openshift-ansible-service-broker
openshift-infra
openshift-node
openshift-template-service-broker
openshift-web-console
rome
samples
* shrimp
Using project "shrimp" on server "https://master.lab.example.com".
2.2 ResourceQuota
2.2.1 ex280-quota.yaml
apiVersion: v1
kind: ResourceQuota
metadata:
name: ex280-quota
spec:
hard:
replicationcontrollers: 3
services: 6
pods: 3
limits.cpu: 2
limits.memory: 1Gi
2.2.2 创建quota
[root@master shrimp]# oc create -f ex280-quota.yaml
resourcequota "ex280-quota" created
2.3 LimitRange
2.3.1 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
defaultRequest:
cpu: 100m
memory: 100Mi
2.3.2 创建
[root@master shrimp]# oc create -f ex280-limits.yaml
limitrange "ex280-limits" created
3. 确认
[root@master shrimp]# oc describe quota ex280-quota
Name: ex280-quota
Namespace: shrimp
Resource Used Hard
-------- ---- ----
limits.cpu 0 2
limits.memory 0 1Gi
pods 0 3
replicationcontrollers 0 3
services 0 6
[root@master shrimp]# oc describe limitrange ex280-limits
Name: ex280-limits
Namespace: shrimp
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 500m -
Container memory 5Mi 300Mi 100Mi 300Mi -