侧边栏壁纸
博主头像
运维日记-记录IT运维经验博主等级

行动起来,活在当下

  • 累计撰写 66 篇文章
  • 累计创建 7 个标签
  • 累计收到 0 条评论

目 录CONTENT

文章目录

containerd

xlong
2024-03-29 / 0 评论 / 0 点赞 / 1 阅读 / 3037 字 / 正在检测是否收录...

containerd

containerd日志优化

方法1: 节点初始化使用KubeletConfiguration声明

apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
cgroupDriver: systemd
failSwapOn: false
containerLogMaxSize: 1024Mi
containerLogMaxFiles: 5

方法2: 更新 ${PATH}/kubelet/config.yaml

# vim /var/lib/kubelet/config.yaml

...<省略若干行>...
containerLogMaxSize: 1024Mi
containerLogMaxFiles: 5
...<省略若干行>...

# systemctl restart kubelet

方法3: 更新kubelet 运行参数

# vim /etc/sysconfig/kubelet
 --container-log-max-files=5 --container-log-max-size="1024Mi" 
 
# systemctl restart kubelet

阿里云ack修改日志大小

查看日志大小:

#! 重要的 !
# 该配置由ACK管理和生成
# 请不要编辑它以避免意外失败

cat /var/lib/kubelet/ack-managed-config.yaml
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
serializeImagePulls: false
cpuManagerPolicy: none
clusterDomain: cluster.local
clusterDNS:
    - 172.16.0.10
tlsCipherSuites:
    - TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256
    - TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
    - TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305
    - TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384
    - TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305
    - TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384
    - TLS_RSA_WITH_AES_256_GCM_SHA384
    - TLS_RSA_WITH_AES_128_GCM_SHA256
maxPods: 256
podPidsLimit: 16384
containerLogMaxSize: 100Mi
containerLogMaxFiles: 10
evictionHard:
    imagefs.available: 15%
    memory.available: 300Mi
    nodefs.available: 10%
    nodefs.inodesFree: 5%
providerID: cn-beijing.i-2zeip4gcg0whr5ezyc73
systemReserved:
    cpu: 100m
    memory: 1779Mi
    pid: "1000"
kubeReserved:
    cpu: 100m
    memory: 1779Mi
    pid: "1000"

验证

可使用以下命令来查看参数是否已经生效:

# kubectl get --raw "/api/v1/nodes/NODENAME/proxy/configz" | jq .
...<省略若干行>...
    "containerLogMaxSize": "200Mi",
    "containerLogMaxFiles": 5,
...<省略若干行>...

Kubelet 针对节点日志限制默认为:

  • containerLogMaxFiles: 5

  • containerLogMaxSize: "50Mi"

0

评论区