Lxcfs K8s 自动注入-解决方案

问题描述
  • 解决用户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

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。