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限制调研

k8s namespace限制调研的更多相关文章

  1. k8s namespace/volume

    https://kubernetes.io/docs/tasks/configure-pod-container/assign-memory-resource/ 只挑个人感觉使用较多/比较重要的点来说 ...

  2. k8s namespace权限问题无法读取configmap

    报错信息: Message: Forbidden!Configured service account doesn't have access. Service account may have be ...

  3. 记一次删除k8s namespace无法删除的问题

    在用longhorn工具做k8s存储卷动态预配的时候,需要修改longhorn.yaml的一个默认参数,修改完成需要重新加载longhorn.yaml,结果重新加载出错了,修改的参数没有生效,于是执行 ...

  4. k8s部署prometheus

    https://www.kancloud.cn/huyipow/prometheus/527092 https://songjiayang.gitbooks.io/prometheus/content ...

  5. spring-cloud-kubernetes服务发现之在k8s环境下开发spring cloud应用

    通常情况下,我们的线上的服务在迁移到k8s环境下的时候,都是采用平滑迁移的方案.服务治理与注册中心等都是采用原先的组件.比如spring cloud应用,在k8s环境下还是用原来的一套注册中心(如eu ...

  6. K8s小白?应用部署太难?看这篇就够了!

    在云原生趋势下,容器和 Kubernetes 可谓是家喻户晓,许多企业内部的研发团队都在使用 Kubernetes 打造 DevOps 平台.从最早的容器概念到 Kubernetes 再到 DevOp ...

  7. kubernetes之监控Operator部署Prometheus(三)

    第一章和第二章中我们配置Prometheus的成本非常高,而且也非常麻烦.但是我们要考虑Prometheus.AlertManager 这些组件服务本身的高可用的话,成本就更高了,当然我们也完全可以用 ...

  8. docker运行php网站程序

    有一个之前的php网站程序需要迁移到K8S,简单调研了下. 基础镜像 官方提供了诸如php:7.1-apache的基础镜像,但是确认必要的扩展,例如gd,当然官方提供了docker-php-ext-i ...

  9. 附006.Kubernetes RBAC授权

    一 RBAC 1.1 RBAC授权 基于角色的访问控制(RBAC)是一种基于个人用户的角色来管理对计算机或网络资源的访问的方法. RBAC使用rbac.authorization.k8s.io API ...

随机推荐

  1. LeetCode | 289. 生命游戏(原地算法/位运算)

    记录dalao的位运算骚操作 根据百度百科 ,生命游戏,简称为生命,是英国数学家约翰·何顿·康威在 1970 年发明的细胞自动机. 给定一个包含 m × n 个格子的面板,每一个格子都可以看成是一个细 ...

  2. Shell:Day05.笔记

    交互输入与for语句 1.交互输入 read  Python中用input()函数,进行输入:  read命令同时可以定义多个变量值:而输入的内容默认以空格为分隔符,将值输入到对应的变量中: 如果默认 ...

  3. layui经典模块化前端UI框架初识

    layui产生背景 layui相对于vue来说确实稍有逊色,但是官网提供的入门文档以及完善的框架结构,使的很多人开始用layui来开发前端页面,那么什么人会去使用layui呢? 针对后端开发人员,在对 ...

  4. Struts2-学习笔记系列(6)-动态调用action

    动态调用之前需要配置: <!--动态方法调用--> <constant name="struts.enable.DynamicMethodInvocation" ...

  5. 智芯微版本的智能配变融合终端交流采集APP

    1.  交采APP基本原理 通过SPI总线周期性的召测交流采集底板的“实时数据”,对“实时数据”变换.加工.统计分析得到“分析数据”和“统计数据”后,通过MQTT总线把这些数据同步到“数据中心”供其他 ...

  6. pgsql中的事务隔离

    pgsql中的事务隔离级别 前言 事物隔离级别 在各个级别上被禁止出现的现象是 脏读 不可重复读 幻读 序列化异常 读已提交隔离级别 可重复读隔离级别 可序列化隔离级别 摘录 pgsql中的事务隔离级 ...

  7. Linux C++ 网络编程学习系列(5)——多路IO之epoll边沿触发

    多路IO之epoll边沿触发+非阻塞 源码地址:https://github.com/whuwzp/linuxc/tree/master/epoll_ET_LT_NOBLOCK_example 源码说 ...

  8. JVM崩溃的原因及解决!

    JVM崩溃的原因及解决! 前些天,搞JNI的时候,报了个JVM崩溃的错.错误信息如下: # # An unexpected error has been detected by HotSpot Vir ...

  9. Python分析数据难吗?某科技大学教授说,很难但有方法就简单

    用python分析数据难吗?某科技大学的教授这样说,很难,但要讲方法,主要是因为并不是掌握了基础,就能用python来做数据分析的. 所谓python的基础,也就是刚入门的python学习者,学习的基 ...

  10. Spring Boot 和 Spring Cloud 应用内存如何管理?

    在整体应用架构中,非生产环境情况下,一般 1GB 或者 2GB 的 RAM 就足够了.如果我们将这个应用程序划分为 20 或 30 个独立的微服务,那么很难期望 RAM 仍将保持在 1GB 或 2GB ...