According to k8s on Microsoft,i have deployed a windows k8s cluster(version 1.12.6) which has one master node on Linux Server and two worker nodes on Windows19 Server. However, the log file produced and locked by kubelet
、 kube-proxy
process occupied several GB disk space。what can I do to rotate the log file for just saving recent days' data on windows Server?
I know Stop
and Start
the kubelet
、kube-proxy
process will help, but my boss said no! :(
I have tried some ways:
# logrotate config
"c:\k\log\kube-proxy.exe.iZcrhcz0q5s4ykZ.NT AUTHORITY_SYSTEM.log.INFO.20190416-162533.2272" {
daily
rotate 5
size 100M
copytruncate
missingok
ifempty
}
rm xxx.log
mv xxx.log
Clear-Content -Path $logFile -Force
All failed!
Error Message: The process cannot access the file 'C:\k\log\xxx.log' because it is being used by another process.
I have some questions:
Thanks for any reply!
kubelet/kube-proxy use klog, klog rotate when file size > 1.8G
func (sb *syncBuffer) Write(p []byte) (n int, err error) {
if sb.nbytes+uint64(len(p)) >= MaxSize {
if err := sb.rotateFile(time.Now(), false); err != nil {
sb.logger.exit(err)
}
}
n, err = sb.Writer.Write(p)
sb.nbytes += uint64(n)
if err != nil {
sb.logger.exit(err)
}
return
}
you can just delete older files.