How to customize container logs configuration, such as max log size or max number of log files through:
containerLogMaxSize and containerLogMaxFilescontainer-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.ymlcontainerLogMaxSize and/or containerLogMaxFiles.# cat /var/vcap/jobs/kubelet/config/kubeletconfig.yml---apiVersion: kubelet.config.k8s.io/v1beta1authentication:anonymous:enabled: falsewebhook:cacheTTL: 0senabled: truex509:clientCAFile: "/var/vcap/jobs/kubelet/config/kubelet-client-ca.pem"authorization:mode: WebhookclusterDNS:- <>clusterDomain: cluster.localcontainerLogMaxSize: 100Mi# monit restart kubelet$ bosh -d service-instance_<xxxx> manifest > service-instance_<xxxx>.manifestcontainerLogMaxSize 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 kubelet4 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.