首页
技术小册
AIGC
面试刷题
技术文章
MAGENTO
云计算
视频课程
源码下载
PDF书籍
「涨薪秘籍」
登录
注册
1. CPU和内存限制
1.1. LimitRange字段
1.2. 默认值案例
1.2.1. 设置默认的request和limit
1.2.2. 不指定request和limit
1.2.3. 指定request,不指定limit
1.2.4. 不指定request,指定limit
1.2.5. 同时指定request和limit
1.3. 极值设置
1.3.1. 设定极值
1.3.2. 超过最大值场景
1.3.3. 低于最小值场景
1.3.4. 一般正常场景
2. 名称空间配额
2.1. 字段
2.2. 计算资源配额
2.3. API资源配额
3. Kubernets集群资源要求
3.1. Kubernetes集群规模限制
3.2. Kubernetes集群配置
当前位置:
首页>>
技术小册>>
Kubernets合辑9-资源约束
小册名称:Kubernets合辑9-资源约束
``` apiVersion: v1 kind: ResourceQuota metadata: name: computer-resource namespace: apps spec: hard: requests.cpu: 1000m requests.memory: 2048Mi limits.cpu: 6000m limits.memory: 8192Mi pods: 3 ``` ``` [root@maxiaoke local-k8s-yaml]# kubectl describe ns apps Name: apps Labels: <none> Annotations: Status: Active Resource Quotas Name: computer-resource Resource Used Hard -------- --- --- limits.cpu 0 6 limits.memory 0 8Gi pods 0 3 requests.cpu 0 1 requests.memory 0 2Gi Resource Limits Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio ---- -------- --- --- --------------- ------------- ----------------------- Container cpu 50m 1 100m 500m - Container memory 64Mi 2Gi 128Mi 1Gi - ``` ``` apiVersion: apps/v1 kind: Deployment metadata: name: slb-deploy namespace: apps spec: replicas: 2 selector: matchLabels: app: slb template: metadata: labels: app: slb spec: containers: - name: slb-demo image: linuxmaxiaoke/nginx:v1.0.0 ``` ``` [root@maxiaoke local-k8s-yaml]# kubectl get deployments.apps -n apps slb-deploy # 当副本数为2时,能运行正常 NAME READY UP-TO-DATE AVAILABLE AGE slb-deploy 2/2 2 2 11s [root@maxiaoke local-k8s-yaml]# kubectl describe ns apps Name: apps Labels: <none> Annotations: Status: Active Resource Quotas Name: computer-resource Resource Used Hard -------- --- --- limits.cpu 1 6 limits.memory 2Gi 8Gi pods 2 3 requests.cpu 200m 1 requests.memory 256Mi 2Gi Resource Limits Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio ---- -------- --- --- --------------- ------------- ----------------------- Container cpu 50m 1 100m 500m - Container memory 64Mi 2Gi 128Mi 1Gi - ``` ``` [root@maxiaoke local-k8s-yaml]# kubectl get deployments.apps -n apps slb-deploy # 当副本数超过3时,超过的部分无法启动 NAME READY UP-TO-DATE AVAILABLE AGE slb-deploy 3/5 3 3 38s [root@maxiaoke local-k8s-yaml]# kubectl describe ns apps Name: apps Labels: <none> Annotations: Status: Active Resource Quotas Name: computer-resource Resource Used Hard -------- --- --- limits.cpu 1500m 6 limits.memory 3Gi 8Gi pods 3 3 requests.cpu 300m 1 requests.memory 384Mi 2Gi Resource Limits Type Resource Min Max Default Request Default Limit Max Limit/Request Ratio ---- -------- --- --- --------------- ------------- ----------------------- Container cpu 50m 1 100m 500m - Container memory 64Mi 2Gi 128Mi 1Gi - ```
上一篇:
2.2. 计算资源配额
下一篇:
3. Kubernets集群资源要求
该分类下的相关小册推荐:
Kubernetes中文教程(三)
Kubernets合辑11-持续集成
Kubernets合辑6-服务发现
Kubernets合辑10-网络
Kubernets合辑3-kubernetes介绍
Kubernetes中文教程(五)
Kubernets合辑8-权限控制
Kubernets合辑2-部署Ingress
Kubernets合辑15-持续部署
Kubernets合辑7-存储
Kubernets合辑14-日志收集
云原生-K8S入门实战