How To Rotate Container Logs on The Master and Worker Nodes

Problem

Container logs are utilizing all the disk space on the master and worker nodes.

Environment

  • Platform9 Managed Kubernetes - All Versions
  • Docker

Cause

The docker service is not configured to rotate the container logs.

Resolution

  1. Back up the /etc/docker/daemon.json file on the affected node if present. Add the log rotation config on the node in the file /etc/docker/daemon.json file as shown below.

Change the values for max-size and max-file parameter as per your requirement.

Sample Config
Copy

Perform the below steps on one node at a time to avoid downtime.

  1. Stop the Platform9 Managed Kubernetes stack by executing commands in the below sequence.
Command 1
Copy
Command 2
Copy
  1. Restart the docker service.
Command
Copy
  1. Start the Platform9 Managed Kubernetes stack by executing the commands in the below sequence.
Command 1
Copy
Command 2
Copy
  1. Verify the changes took effect on the container by running below command.
Command
Copy
Command
Copy
Type to search, ESC to discard
Type to search, ESC to discard
Type to search, ESC to discard