I download a pod's log, it has size bigger then 1G, how to shrike/truncate the pod's log? so I can download it faster?
PS: I need erase the old part of logs so I can free the disk space
kubectl logs --tail=1000 to show only the most recent 1000 lines. Adjust as needed.
--tail=-1: Lines of recent log file to display. Defaults to -1 with no selector, showing all log lines otherwise 10, if a selector is provided.
Also to add to Coderangers answer if you want a time based truncate. This is how you can get the last 1 hour's logs.
kubectl logs --since=1h nginxShows all logs from pod nginx written in the last hour.
Update Post Comment.
The pod and container logs are stored in respective applications paths. Refer to this answer. https://stackoverflow.com/a/50872881/5617140
Another solution is the truncation of the docker logs in each for your kubernetes nodes.
sudo sh -c "du -ch /var/lib/docker/containers/*/*-json.log | grep total"
This will give total size of docker logs.
sudo sh -c "truncate -s 0 /var/lib/docker/containers/*/*-json.log"
Above command will truncate all the log files. Note* - This is a workaround solution. Make sure you backup the important logs before doing this.