kubernetes how to set the maximum size of the log file?
Asked Answered
P

1

13

How to set the maximum size of the log file? Or enable log rotation. In the documentation I have not found anything about this.

Or it is necessary to write a script for this?

Polyzoan answered 18/8, 2016 at 15:15 Comment(3)
Did you manage to resolve thisPoyang
I have not found a good way. I wrote a script which gets all namespaces and then all pods in the system. Then I get the information on what host and container id. With this data the script does a SSH $user@$node "sudo truncate -s 0 /var/lib/Docker/containers/$id/$id-json.log" But I have not tested it fullyPolyzoan
Maximum log size for what? What environment are you running on? Log rotation should be setup if you're using any of the default deployments (via salt)Bridlewise
P
5

I don't think kubernetes provides log rotation feature now. You can put logrotate configuration in your host machine. Something like this one:

/var/lib/docker/containers/*/*.log {
  rotate 7
  daily
  size=10M
  compress
  missingok
  delaycompress
  copytruncate
}
Portmanteau answered 23/12, 2016 at 1:29 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.