为deployment设置cpu/memory资源配额
设置cpu/memory配置请求资源配额和限制资源配额
生产deployment配置yaml文件
kubectl create deployment cpu-memory-quota --image=nginx --replicas=4 --dry-run=client -n openeuler -o yaml > cpu-memory-quota.yaml
vim cpu-memory-quota.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: cpu-memory-quota
name: cpu-memory-quota
namespace: openeuler
spec:
replicas: 4
selector:
matchLabels:
app: cpu-memory-quota
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: cpu-memory-quota
spec:
containers:
- image: nginx
name: cpu-memory-quota
resources:
limits:
cpu: 2
memory: 2Gi
requests:
cpu: 100m
memory: 128Mi
status: {}
kubectl apply -f cpu-memory-quota.yaml
验证效果
kubectl get pods -n openeuler cpu-memory-quota-cfb8bdf9f-8cm2m -o yaml | grep resources -A6
resources:
limits:
cpu: "2"
memory: 2Gi
requests:
cpu: 100m
memory: 128Mi