天天看點

OPENSHIFT-280-7-為項目建立定額與限額

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        -

繼續閱讀