How to customize container logs configuration, such as max log size or max number of log files through:
containerLogMaxSize
and containerLogMaxFiles
container-log-max-size
and container-log-max-files
"/var/vcap/jobs/kubelet/config/kubeletconfig.yml"
inside the nodes.There are two ways to set up the max log files' size and max number of log files.
# vim /var/vcap/jobs/kubelet/config/kubeletconfig.yml
containerLogMaxSize
and/or containerLogMaxFiles
.# cat /var/vcap/jobs/kubelet/config/kubeletconfig.yml
---
apiVersion: kubelet.config.k8s.io/v1beta1
authentication:
anonymous:
enabled: false
webhook:
cacheTTL: 0s
enabled: true
x509:
clientCAFile: "/var/vcap/jobs/kubelet/config/kubelet-client-ca.pem"
authorization:
mode: Webhook
clusterDNS:
- <>
clusterDomain: cluster.local
containerLogMaxSize: 100Mi
# monit restart kubelet
$ bosh -d service-instance_<xxxx> manifest > service-instance_<xxxx>.manifest
containerLogMaxSize
equal to 100Mi.$ cat ops.yaml
- type: replace path: /instance_groups/name=worker/jobs/name=kubelet/properties/kubelet-configuration/containerLogMaxSize? value: 100Mi
$ bosh -d service-instance_<xxxx> deploy service-instance_<xxxx>.manifest -o ops.yaml
The steps below allow you to configure container-log-max-size
and container-log-max-files
passed to kubelet as command flags instead of through the kubelet config file.
This method is deprecated and you'll find messages like the one below in /var/vcap/sys/log/kubelet/kubelet.stderr.log
:
Flag --container-log-max-size has been deprecated, This parameter should be set via the config file specified by the Kubelet's --config flag. See https://kubernetes.io/docs/tasks/administer-cluster/kubelet-config-file/ for more information.
To create experimental customized K8s Profile, please refer to the official Docs: https://docs.vmware.com/en/VMware-Tanzu-Kubernetes-Grid-Integrated-Edition/1.19/tkgi/GUID-k8s-profiles.html
Please note: Experimental customizations are NOT validated or supported by TKGi team (same would be mentioned in above document)
"container-log-max-size": "500Mi"
as an example below).{ "name":"kubelet-log", "description":"kubelet profile", "experimental_customizations":[ { "component":"kubelet", "arguments":{ "container-log-max-size": "500Mi" } } ] }
tkgi create-kubernetes-profile <kubernetes-profile-JSON-path>
tkgi update-cluster <Cluster-Name> --kubernetes-profile <Kubernetes-Profile-Name>
----> ** This will trigger changes in the cluster # ps -elf | grep kubelet
# ps -elf | grep kubelet
4 S root 461105 461054 4 70 -10 - 506263 futex_ 13:09 ? 00:02:01 kubelet --container-log-max-size=500Mi
N.B: container-log-max-files
parameter can be added like wise container-log-max-size
in the K8s Profile.