SUSE Support

Here When You Need Us

How to set container log rotation with RKE2

This document (000021045) is provided subject to the disclaimer at the end of this document.

Environment

Container Log rotation with RKE2

Situation

In a Kubernetes cluster running an alternative container runtime, such as containerd, instead of Docker, the kubelet manages container logs. The kubelet default values in relation to log rotation can be found in the upstream kubelet | Kubernetes documentation. These values can be adjusted by adding options to the kubelet process.

Resolution

Two kubelet options need to be added to RKE2 config file, /etc/rancher/rke2/config.yaml

kubelet-arg:                               
  - "container-log-max-files=5"            
  - "container-log-max-size=10Mi" 

Note please adjust the values to suit your needs, for demonstration purposes the above commands used 5 log files of 10MB, allowing for 50MB of total space to be retained per container.

 

Additional Information

Here is a reference to K3s (which have a similar way to see using CLIt) for setting through binary command.(RKE2 CLI example page)

Disclaimer

This Support Knowledgebase provides a valuable tool for SUSE customers and parties interested in our products and solutions to acquire information, ideas and learn from one another. Materials are provided for informational, personal or non-commercial use within your organization and are presented "AS IS" WITHOUT WARRANTY OF ANY KIND.

  • Document ID:000021045
  • Creation Date: 18-Apr-2023
  • Modified Date:29-Feb-2024
    • SUSE Rancher

< Back to Support Search

For questions or concerns with the SUSE Knowledgebase please contact: tidfeedback[at]suse.com

tick icon

SUSE Support Forums

Get your questions answered by experienced Sys Ops or interact with other SUSE community experts.

tick icon

Support Resources

Learn how to get the most from the technical support you receive with your SUSE Subscription, Premium Support, Academic Program, or Partner Program.

tick icon

Open an Incident

Open an incident with SUSE Technical Support, manage your subscriptions, download patches, or manage user access.