Home > database >  is it possible to limit the pod log in kubernetes
is it possible to limit the pod log in kubernetes

Time:05-04

Today I found the cloud host disk was full using this command:

[root@uat-k8s-02 home]# find / -type f -size  800000 -print0 | xargs -0 du -h | sort -nr

the output shows that some app in pod take too much space, is it possible to set the max size of pod or limit the pod folder size in kubernetes? The big log file may look like this:

11G /var/lib/docker/overlay2/324b88134dad57cf39074a46bfeb61cdadf431b3d84055b8fc66eb1bef0fbfed/diff/data/applogs/xxl-job/xxl-job-admin.log

CodePudding user response:

The ephemeral-storage limit can be set to limit the amount of ephemeral storage a pod can use. Here is an example.

spec:
  containers:
  - name: app
    image: images.my-company.example/app:v4
    resources:
      requests:
        ephemeral-storage: "2Gi"
      limits:
        ephemeral-storage: "4Gi"

Relevant documentation can be found here: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/

CodePudding user response:

From the kubernetes official documentation for kubelet configuration we have two parameters which limits the pod logs:

--container-log-max-files int32 Set the maximum number of container log files that can be present for a container. The number must be >= 2

--container-log-max-size string Set the maximum size (e.g. 10Mi) of container log file before it is rotated. This flag can only be used with --container-runtime=remote

You can refer the documentation here: kubelet reference file

  • Related