问题描述
- 解决用户exec进入容器内部后free -h 查看内存大小
- 解决程序在获取内存时超量,导致超过limit被K8s重启
方案介绍
# 目录介绍
app/ #存放用于处理api发来的yaml相关信息
deploy/ #用于存放部署用到的资源
deployment-lxcfs-demo.sh #部署脚本
un-deployment-lxcfs-demo.sh #卸载部署的相关配置
test/ #测试用到的yaml文件
部署测试
Login required K8s Master
# git clone git@github.com:The-Last-Name/lxcfs-webhook.git
# bash deployment-lxcfs-demo.sh
测试效果
# kubectl create ns test1
# cat test/deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: null
labels:
app: centos-test
name: centos-test
spec:
replicas: 1
selector:
matchLabels:
app: centos-test
strategy: {}
template:
metadata:
creationTimestamp: null
labels:
app: centos-test
spec:
containers:
- image: daocloud.io/library/centos:7
imagePullPolicy: IfNotPresent
name: centos
command: ['tail', '-f', '/etc/hosts']
resources:
limits:
cpu: 1
memory: 2Gi
requests:
cpu: 1
memory: 2Gi
# kubectl apply -f test/deployment.yaml -n test1
# kubectl get pod -n test1
# kubectl exec -it centos-test-b6495cfb8-r9fk8 -n test1 -- free -h
网友评论