How to configure rolling OR delete after X time of data dir , to prevent "out of space" error

i configured the cluster to claim 5g for the data dir

    volumeClaimTemplates:
    - metadata:
        name: elasticsearch-data
      spec:
        accessModes:
        - ReadWriteOnce
        resources:
          requests:
            storage: 5Gi

I like to configure the cluster to roll data for example after it Reaches 4g
or another method that elastic search is using, the main point is that i don't want it to throw
"out of space" error when data is Reaches to 5g
Thanks

Roll it where?
Have you looked at ILM?