問題描述
- 解決用戶exec進入容器內(nèi)部后free -h 查看內(nèi)存大小
- 解決程序在獲取內(nèi)存時超量辨萍,導致超過limit被K8s重啟
方案介紹
# 目錄介紹
app/ #存放用于處理api發(fā)來的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