Home > other >  Kubernetes pod logs retention
Kubernetes pod logs retention

Time:04-22

I have joined a project where we deploy our apps on Azure cloud. The apps are in docker containers orchestrated by kubernetes.

We get the data from a POD log file with this command (YAML code below)

kubectl logs --namespace=app-prod
deployment/app-fd-prod
> $(logFile)

where logFile is a variable

Now the problem is, yesterday the log file was 27MB. Today the log file is 2MB that means the old data got deleted some how.

I have read about logRotate but i dont think we have implemented that.

I want to know what can be the reason of deletion of yesterday's log file text ?

Any leads, helps would be appreciated.

CodePudding user response:

pod logs get rotated for you as pointed out by @jordanm in the comments. You need a log aggregation tool like the ELK/EFK stack (Elastic Logstash kibana or Elastic fluentd kibana) or Promtail loki grafana. These stacks tail the logs of containers, do some fancy parsing / manipulation and ships it to persistent storage like S3.

Side note you can take a look at the logging operator that makes the config of these things a little easier.

  • Related