dundee / gdu

Fast disk usage analyzer with console interface written in Go
MIT License
3.75k stars 137 forks source link

Get top large files #348

Open devopsmash opened 4 months ago

devopsmash commented 4 months ago

I have a scenario where one of my Kubernetes nodes is experiencing disk pressure. Due to my use of the Bottlerocket OS, it's somewhat challenging to run utilities that are not containerized.

I tried to use the gdu docker image and get the files that cause the disk pressure, unfortunately without any success.

It would be amazing if I could run a k8s job like this and get the top X large files

apiVersion: batch/v1
kind: Job
metadata:
  name: disk-space-checker
  labels:
    app: disk-space-checker
    release: disk-space-checker
spec:
  backoffLimit: 0
  parallelism: 1
  ttlSecondsAfterFinished: 3600 # keep job for 1 hour 
  activeDeadlineSeconds: 900 # timeout after 15 min   
  template:
    metadata:
      labels:
        app: disk-space-checker
    spec:
      restartPolicy: Never
      containers:
      - name: disk-space-checker
        image: ghcr.io/dundee/gdu:v5.28.0
        imagePullPolicy: IfNotPresent
        securityContext:
          runAsUser: 0
        resources:
          requests:
            cpu: 250m
        args: ["--non-interactive","--show-apparent-size","--show-item-count","--max-cores","4","--no-delete","--ignore-dirs","/host/proc,/host/dev,/host/sys,/host/run,/host/local,/host/mnt,/host/etc,/host/boot","--no-cross","/host"]
        volumeMounts:
        - name: host
          mountPath: "/host"
          readOnly: true
      volumes:
        - name: host
          hostPath:
            path: "/"

With this k8s job I gets only root directories without getting sub directories and files.

Any chance to have additional parameter that can sort top X files by size?

dundee commented 4 months ago

This sounds like a valid use case. I will try to add it to the next release.