<p>According to <a href="https://learn.microsoft.com/en-us/virtualization/windowscontainers/kubernetes/getting-started-kubernetes-windows" rel="nofollow noreferrer">k8s on Microsoft</a>,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 <code>kubelet</code>、 <code>kube-proxy</code> process occupied several GB disk space。what can I do to rotate the log file for just saving recent days' data on windows Server? </p>

<p>I know <code>Stop</code> and <code>Start</code> the <code>kubelet</code>、<code>kube-proxy</code> process will help, but my boss said no! :(</p>

<p>I have tried some ways:</p>

<ol>
<li><a href="https://sourceforge.net/projects/logrotatewin/" rel="nofollow noreferrer">window logrotate tool</a></li>
</ol>

<pre><code># 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
}
</code></pre>

<ol start="2">
<li>powershell cmd</li>
</ol>

<pre><code>rm xxx.log
mv xxx.log
Clear-Content -Path $logFile -Force
</code></pre>

<p>All failed! </p>

<p>Error Message: <code>The process cannot access the file 'C:\k\log\xxx.log' because it is being used by another process.</code></p>

<p>I have some questions:</p>

<ul>
<li>1: Does k8s' log system support logrotate on Windows?</li>
<li>2: Does Windows Server provide a mechanism to rotate log?</li>
</ul>

<p>Thanks for any reply!</p>

Jimmy Zhang
<p>kubelet/kube-proxy use klog, klog rotate when file size > 1.8G</p>

<pre class="lang-golang prettyprint-override"><code>
func (sb *syncBuffer) Write(p []byte) (n int, err error) {
    if sb.nbytes+uint64(len(p)) &gt;= 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
}
</code></pre>

<p>you can just delete older files.</p>
