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"
评论区