k8s namespace限制调研
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限制调研
低调大师中文资讯倾力打造互联网数据资讯、行业资源、电子商务、移动互联网、网络营销平台。
持续更新报道IT业界、互联网、市场资讯、驱动更新,是最及时权威的产业资讯及硬件资讯报道平台。
转载内容版权归作者及来源网站所有,本站原创内容转载请注明来源。
- 上一篇
k8s 心得
安装: 我们通过kubeadm工具安装,安装些基本组件 如 kubeadm kubectl kubelet,其他通过kubeadm配 置启动,具体在kubeadm init的时候都会打印出来,可以看到。 单独安装docker,并且k8s对docker兼容的版本有限制,并不支持最近的docker版本。k8s会支持不仅一种容器,不仅是docker。 组件作用: kubeadm 用来master初始化集群 node加入集群 kubectl 脚本命令包 用来对集群操作的,授权之后就可以对集群操作了。可以用root 非root用户操作。可以在master机器(默认)上授权操作。猜测也可以在node机器,集群外机器(接口机)上授权操作。 kubelet 每台节点都要安装,集成了cAdvisor,收集本机信息,node与master通信。 kubeadm在初始化集群时还会通过docker启动一些服务,master独有etcd,apiserver,kube-controller-manager,kube-scheduler,kube-dns。每台机器上都会启动kube-proxy。如果使用了flann...
- 下一篇
k8s api文档 调用heapster metrics
restfulapi访问k8s集群,增删改查信息,做界面二次开 发。需要预先创建访问权限的配置。 官网api文档https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.9/版本更新到v1.10以后上面这个链接就找不到了要把v1.9改成v1.10才能访问。https://kubernetes.io/docs/reference/generated/kubernetes-api/v1.10/ 下面罗列部分api curl -u admin:admin "https://localhost:6443/api/v1" -k curl -u admin:admin "https://localhost:6443/api/v1/pods" -k curl -u admin:admin "https://localhost:6443/api/v1/namespaces/{namespace}/pods" -k curl -u admin:admin "https://localhost:6443/api/v1/namespac...
相关文章
文章评论
共有0条评论来说两句吧...