1.创建namespace gpu

2.增加限制

[root@tensorflow1 gpu-namespace]# cat compute-resources.yaml

apiVersion: v1

kind: ResourceQuota

metadata:

name: compute-resources

namespace: gpu

spec:

hard:

pods: "5"

requests.cpu: "1"

requests.memory: 1Gi

limits.cpu: "2"

limits.memory: 2Gi

[root@tensorflow1 gpu-namespace]# kubectl describe namespace gpu

Name: gpu

Labels: <none>

Annotations: <none>

Status: Active

Resource Quotas

Name: compute-resources

Resource Used Hard

-------- --- ---

limits.cpu 0 2

limits.memory 0 2Gi

pods 4 5

requests.cpu 0 1

requests.memory 0 1Gi

No resource limits.

3.检查限制情况

在已经创建好容器的情况下再增加限制,发现限 制并没有起作用,预期是memory限制到2g,结果是 从容器内仍然能看到8g内存

容器内:

root@tensorflow-ps-rc-cm9c8:/notebooks# free -m

total used free shared buff/cache available

Mem: 7783 1615 274 251 5893 5383

Swap: 0 0 0

宿主机:

[root@tensorflow0 ~]# free -m

total used free shared buff/cache available

Mem: 7783 1616 272 251 5894 5382

Swap: 0 0 0

4.杀掉容器

容器启动失败,要求对容器添加限制

[root@tensorflow1 gpu-namespace]# kubectl describe rc/tensorflow-ps-rc -n gpu

...

Warning FailedCreate 2m replication-controller Error creating: pods "tensorflow-ps-rc-jrxxl" is forbidden: failed quota: compute-resources: must specify limits.cpu,limits.memory,requests.cpu,requests.memory

Warning FailedCreate 23s (x9 over 2m) replication-controller (combined from similar events): Error creating: pods "tensorflow-ps-rc-sw9wx" is forbidden: failed quota: compute-resources: must specify limits.cpu,limits.memory,requests.cpu,requests.memory

5.配置好限制,重启启动

增加配置:

resources:

requests:

memory: "1024Mi"

cpu: "250m"

limits:

memory: "1024Mi"

cpu: "500m"

只启动了一个[root@tensorflow1 tf_gpu]# kubectl get all -o wide -n gpu

NAME READY STATUS RESTARTS AGE IP NODE

po/tensorflow-ps-rc-9m8zj 1/1 Running 0 1h 10.244.2.91 tensorflow0

po/tensorflow-worker-rc-5zq9q 1/1 Running 0 11d 10.244.2.61 tensorflow0

po/tensorflow-worker-rc-mhncr 1/1 Running 0 11d 10.244.1.87 tensorflow2

NAME DESIRED CURRENT READY AGE CONTAINERS IMAGES SELECTOR

rc/tensorflow-ps-rc 2 1 1 1h ps nfs:5000/tensorflow/tensorflow:nightly name=tensorflow-ps

rc/tensorflow-worker-rc 2 2 2 11d worker nfs:5000/tensorflow/tensorflow:nightly-gpu name=tensorflow-worker

NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE SELECTOR

svc/tensorflow-ps-service ClusterIP 10.99.156.187 <none> 2222/TCP 11d name=tensorflow-ps

svc/tensorflow-wk-service ClusterIP 10.102.251.161 <none> 2222/TCP 11d name=tensorflow-worker

第二个不满足条件了

[root@tensorflow1 tf_gpu]# kubectl describe namespace gpu

Name: gpu

Labels: <none>

Annotations: <none>

Status: Active

Resource Quotas

Name: compute-resources

Resource Used Hard

-------- --- ---

limits.cpu 500m 2

limits.memory 1Gi 2Gi

pods 3 5

requests.cpu 250m 1

requests.memory 1Gi 1Gi

No resource limits.

[root@tensorflow1 tf_gpu]# kubectl describe rc/tensorflow-ps-rc -n gpu

Warning FailedCreate 3m replication-controller Error creating: pods "tensorflow-ps-rc-cbt6c" is forbidden: exceeded quota: compute-resources, requested: requests.memory=1Gi, used: requests.memory=1Gi, limited: requests.memory=1Gi

6.进入启动成功的那个容器

宿主机内存

[root@tensorflow0 ~]# free -m

total used free shared buff/cache available

Mem: 7783 1433 450 251 5899 5567

Swap: 0 0 0

容器内存,与外面看到的一致。

root@tensorflow-ps-rc-9m8zj:/notebooks# free -m

total used free shared buff/cache available

Mem: 7783 1433 450 251 5899 5567

Swap: 0 0 0

虽然限制了1G内存,但是仍能看到8G内存

本文转自CSDN-k8s namespace限制调研

最新文章

  1. MFC 如何创建浏览文件夹的对话框
  2. R语言进行数据预处理wranging
  3. 各大Oj平台介绍 刷题平台
  4. Qt报表控件NCReport教程:添加报表字段
  5. linux 下 jdk+tomcat+mysql 的 jsp 环境搭建
  6. git还原成某个点
  7. 【转】Apache Options Indexes FollowSymLinks详解
  8. Android中Json数据读取与创建
  9. DJANGO,获取当前用户名,用户组名,用户组权限
  10. Dialog( 对话框) 组件
  11. Flex中通过RadioButton进行切换
  12. python常用命令(持续) | Commonly used Python command list (con&#39;t)
  13. 50款经典电影效果LR预设
  14. macbook查找卸载pkg
  15. VS 错误: 未找到与约束contractname Microsoft.VisualStudio.Utilities.IContentTypeRegistryService
  16. JDK文档中关于Semaphore的正确使用以及使用场景
  17. Nginx性能调优
  18. linux 实用命令 —— tr
  19. Flex学习笔记,脚本式验证
  20. smarty获取php中的变量

热门文章

  1. 1040 Longest Symmetric String (25分)(dp)
  2. 本地Vue项目跨域请求本地Node.js服务器的配置方法
  3. 【JavaScript】js02
  4. Kafka,RocketMQ,RabbitMQ部署与使用体验
  5. docker-compose容器中redis权限问题
  6. JavaScript 入门 (一)
  7. mysql报错: unknown variable &#39;sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES&#39;
  8. 游戏开服 报一些 ip 设置 数据格式的异常,但断点明明都是数字 没问题的
  9. java解惑之常常忘记的事
  10. mysql 不能对同一个表进行 update(delete) 和 select 联合操作