parent
1089ebbf41
commit
4050303130
|
|
@ -213,159 +213,160 @@ works as follows:
|
||||||
- Pods in the cluster have one of the three priority classes, "low", "medium", "high".
|
- Pods in the cluster have one of the three priority classes, "low", "medium", "high".
|
||||||
- One quota object is created for each priority.
|
- One quota object is created for each priority.
|
||||||
|
|
||||||
1. Save the following YAML to a file `quota.yml`.
|
Save the following YAML to a file `quota.yml`.
|
||||||
|
|
||||||
```yaml
|
```yaml
|
||||||
apiVersion: v1
|
apiVersion: v1
|
||||||
kind: List
|
kind: List
|
||||||
items:
|
items:
|
||||||
- apiVersion: v1
|
- apiVersion: v1
|
||||||
kind: ResourceQuota
|
kind: ResourceQuota
|
||||||
metadata:
|
metadata:
|
||||||
name: pods-high
|
name: pods-high
|
||||||
spec:
|
spec:
|
||||||
hard:
|
hard:
|
||||||
cpu: "1000"
|
cpu: "1000"
|
||||||
memory: 200Gi
|
memory: 200Gi
|
||||||
pods: "10"
|
pods: "10"
|
||||||
scopeSelector:
|
scopeSelector:
|
||||||
matchExpressions:
|
matchExpressions:
|
||||||
- operator : In
|
- operator : In
|
||||||
scopeName: PriorityClass
|
scopeName: PriorityClass
|
||||||
values: ["high"]
|
values: ["high"]
|
||||||
- apiVersion: v1
|
- apiVersion: v1
|
||||||
kind: ResourceQuota
|
kind: ResourceQuota
|
||||||
metadata:
|
metadata:
|
||||||
name: pods-medium
|
name: pods-medium
|
||||||
spec:
|
spec:
|
||||||
hard:
|
hard:
|
||||||
cpu: "10"
|
cpu: "10"
|
||||||
memory: 20Gi
|
memory: 20Gi
|
||||||
pods: "10"
|
pods: "10"
|
||||||
scopeSelector:
|
scopeSelector:
|
||||||
matchExpressions:
|
matchExpressions:
|
||||||
- operator : In
|
- operator : In
|
||||||
scopeName: PriorityClass
|
scopeName: PriorityClass
|
||||||
values: ["medium"]
|
values: ["medium"]
|
||||||
- apiVersion: v1
|
- apiVersion: v1
|
||||||
kind: ResourceQuota
|
kind: ResourceQuota
|
||||||
metadata:
|
metadata:
|
||||||
name: pods-low
|
name: pods-low
|
||||||
spec:
|
spec:
|
||||||
hard:
|
hard:
|
||||||
cpu: "5"
|
cpu: "5"
|
||||||
memory: 10Gi
|
memory: 10Gi
|
||||||
pods: "10"
|
pods: "10"
|
||||||
scopeSelector:
|
scopeSelector:
|
||||||
matchExpressions:
|
matchExpressions:
|
||||||
- operator : In
|
- operator : In
|
||||||
scopeName: PriorityClass
|
scopeName: PriorityClass
|
||||||
values: ["low"]
|
values: ["low"]
|
||||||
```
|
```
|
||||||
|
|
||||||
2. Apply it using `kubectl create`.
|
Apply the YAML using `kubectl create`.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl create -f ./quota.yml
|
kubectl create -f ./quota.yml
|
||||||
|
|
||||||
resourcequota/pods-high created
|
resourcequota/pods-high created
|
||||||
resourcequota/pods-medium created
|
resourcequota/pods-medium created
|
||||||
resourcequota/pods-low created
|
resourcequota/pods-low created
|
||||||
```
|
```
|
||||||
|
|
||||||
3. Verify that `Used` quota is `0` using `kubectl describe quota`.
|
Verify that `Used` quota is `0` using `kubectl describe quota`.
|
||||||
|
|
||||||
```shell
|
```shell
|
||||||
kubectl describe quota
|
kubectl describe quota
|
||||||
|
|
||||||
Name: pods-high
|
Name: pods-high
|
||||||
Namespace: default
|
Namespace: default
|
||||||
Resource Used Hard
|
Resource Used Hard
|
||||||
-------- ---- ----
|
-------- ---- ----
|
||||||
cpu 0 1k
|
cpu 0 1k
|
||||||
memory 0 200Gi
|
memory 0 200Gi
|
||||||
pods 0 10
|
pods 0 10
|
||||||
|
|
||||||
|
|
||||||
Name: pods-low
|
Name: pods-low
|
||||||
Namespace: default
|
Namespace: default
|
||||||
Resource Used Hard
|
Resource Used Hard
|
||||||
-------- ---- ----
|
-------- ---- ----
|
||||||
cpu 0 5
|
cpu 0 5
|
||||||
memory 0 10Gi
|
memory 0 10Gi
|
||||||
pods 0 10
|
pods 0 10
|
||||||
|
|
||||||
|
|
||||||
Name: pods-medium
|
Name: pods-medium
|
||||||
Namespace: default
|
Namespace: default
|
||||||
Resource Used Hard
|
Resource Used Hard
|
||||||
-------- ---- ----
|
-------- ---- ----
|
||||||
cpu 0 10
|
cpu 0 10
|
||||||
memory 0 20Gi
|
memory 0 20Gi
|
||||||
pods 0 10
|
pods 0 10
|
||||||
```
|
```
|
||||||
4. Create a pod with priority "high". Save the following YAML to a
|
|
||||||
file `high-priority-pod.yml`.
|
|
||||||
|
|
||||||
```yaml
|
Create a pod with priority "high". Save the following YAML to a
|
||||||
apiVersion: v1
|
file `high-priority-pod.yml`.
|
||||||
kind: Pod
|
|
||||||
metadata:
|
|
||||||
name: high-priority
|
|
||||||
spec:
|
|
||||||
containers:
|
|
||||||
- name: high-priority
|
|
||||||
image: ubuntu
|
|
||||||
command: ["/bin/sh"]
|
|
||||||
args: ["-c", "while true; do echo hello; sleep 10;done"]
|
|
||||||
resources:
|
|
||||||
requests:
|
|
||||||
memory: "10Gi"
|
|
||||||
cpu: "500m"
|
|
||||||
limits:
|
|
||||||
memory: "10Gi"
|
|
||||||
cpu: "500m"
|
|
||||||
priorityClassName: high
|
|
||||||
```
|
|
||||||
|
|
||||||
Apply it with `kubectl create`.
|
```yaml
|
||||||
|
apiVersion: v1
|
||||||
|
kind: Pod
|
||||||
|
metadata:
|
||||||
|
name: high-priority
|
||||||
|
spec:
|
||||||
|
containers:
|
||||||
|
- name: high-priority
|
||||||
|
image: ubuntu
|
||||||
|
command: ["/bin/sh"]
|
||||||
|
args: ["-c", "while true; do echo hello; sleep 10;done"]
|
||||||
|
resources:
|
||||||
|
requests:
|
||||||
|
memory: "10Gi"
|
||||||
|
cpu: "500m"
|
||||||
|
limits:
|
||||||
|
memory: "10Gi"
|
||||||
|
cpu: "500m"
|
||||||
|
priorityClassName: high
|
||||||
|
```
|
||||||
|
|
||||||
```shell
|
Apply it with `kubectl create`.
|
||||||
kubectl create -f ./high-priority-pod.yml
|
|
||||||
```
|
|
||||||
|
|
||||||
5. Verify that "Used" stats for "high" priority quota, `pods-high`, has changed and that
|
```shell
|
||||||
the other two quotas are unchanged.
|
kubectl create -f ./high-priority-pod.yml
|
||||||
|
```
|
||||||
|
|
||||||
```shell
|
Verify that "Used" stats for "high" priority quota, `pods-high`, has changed and that
|
||||||
kubectl describe quota
|
the other two quotas are unchanged.
|
||||||
|
|
||||||
Name: pods-high
|
```shell
|
||||||
Namespace: default
|
kubectl describe quota
|
||||||
Resource Used Hard
|
|
||||||
-------- ---- ----
|
Name: pods-high
|
||||||
cpu 500m 1k
|
Namespace: default
|
||||||
memory 10Gi 200Gi
|
Resource Used Hard
|
||||||
pods 1 10
|
-------- ---- ----
|
||||||
|
cpu 500m 1k
|
||||||
|
memory 10Gi 200Gi
|
||||||
|
pods 1 10
|
||||||
|
|
||||||
|
|
||||||
Name: pods-low
|
Name: pods-low
|
||||||
Namespace: default
|
Namespace: default
|
||||||
Resource Used Hard
|
Resource Used Hard
|
||||||
-------- ---- ----
|
-------- ---- ----
|
||||||
cpu 0 5
|
cpu 0 5
|
||||||
memory 0 10Gi
|
memory 0 10Gi
|
||||||
pods 0 10
|
pods 0 10
|
||||||
|
|
||||||
|
|
||||||
Name: pods-medium
|
Name: pods-medium
|
||||||
Namespace: default
|
Namespace: default
|
||||||
Resource Used Hard
|
Resource Used Hard
|
||||||
-------- ---- ----
|
-------- ---- ----
|
||||||
cpu 0 10
|
cpu 0 10
|
||||||
memory 0 20Gi
|
memory 0 20Gi
|
||||||
pods 0 10
|
pods 0 10
|
||||||
```
|
```
|
||||||
|
|
||||||
`scopeSelector` supports the following values in the `operator` field:
|
`scopeSelector` supports the following values in the `operator` field:
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue