98 lines
1.3 KiB
Markdown
98 lines
1.3 KiB
Markdown
**示例1:配置默认的requests和limits**
|
||
|
||
```
|
||
apiVersion: v1
|
||
kind: LimitRange
|
||
metadata:
|
||
name: cpu-mem-limit-range
|
||
spec:
|
||
limits:
|
||
- default:
|
||
cpu: 1
|
||
memory: 512Mi
|
||
defaultRequest:
|
||
cpu: 0.5
|
||
memory: 256Mi
|
||
type: Container
|
||
---
|
||
apiVersion: v1
|
||
kind: Pod
|
||
metadata:
|
||
name: default-cpu-demo
|
||
spec:
|
||
containers:
|
||
- name: default-cpu-demo-ctr
|
||
image: nginx
|
||
|
||
```
|
||
|
||
**示例2:配置requests和limits的范围**
|
||
|
||
```
|
||
apiVersion: v1
|
||
kind: LimitRange
|
||
metadata:
|
||
name: cpu-min-max-demo-lr
|
||
spec:
|
||
limits:
|
||
- max:
|
||
cpu: "800m"
|
||
memory: 1Gi
|
||
min:
|
||
cpu: "200m"
|
||
memory: 500Mi
|
||
type: Container
|
||
---
|
||
apiVersion: v1
|
||
kind: Pod
|
||
metadata:
|
||
name: constraints-mem-demo-2
|
||
spec:
|
||
containers:
|
||
- name: constraints-mem-demo-2-ctr
|
||
image: nginx
|
||
resources:
|
||
limits:
|
||
memory: "1.5Gi"
|
||
requests:
|
||
memory: "800Mi"
|
||
|
||
```
|
||
|
||
```
|
||
apiVersion: v1
|
||
kind: Pod
|
||
metadata:
|
||
name: constraints-mem-demo-3
|
||
spec:
|
||
containers:
|
||
- name: constraints-mem-demo-3-ctr
|
||
image: nginx
|
||
resources:
|
||
limits:
|
||
memory: "800Mi"
|
||
requests:
|
||
memory: "100Mi"
|
||
|
||
```
|
||
|
||
**示例3:限制申请存储空间的大小**
|
||
|
||
```
|
||
apiVersion: v1
|
||
kind: LimitRange
|
||
metadata:
|
||
name: storagelimits
|
||
spec:
|
||
limits:
|
||
- type: PersistentVolumeClaim
|
||
max:
|
||
storage: 2Gi
|
||
min:
|
||
storage: 1Gi
|
||
|
||
```
|
||
|
||
|
||
|