I have a PostgreSQL database deployed in a Kubernetes cluster using a StatefulSet, which is being used by Prefect. I’m facing a major issue with storage space running out frequently. I have observed that manually deleting rows from the log table doesn’t reclaim disk space. However, running VACUUM FULL on the log table helps to reclaim the space effectively.
I want to automate this process so that a service can:
Automatically delete older log entries (more than 7 days old) from the log table.
Run VACUUM FULL on the table to reclaim disk space.
Key Points to Consider:
Database Setup: PostgreSQL is deployed as a StatefulSet in a Kubernetes cluster.
Automation Requirement: I need an automated process that will regularly check for old log entries, delete them, and reclaim the disk space.
I would appreciate any guidance on how to set up this automated cleanup and space reclamation in a Kubernetes environment. Should I use a Kubernetes CronJob, or is there a more effective approach? Any tips on configurations or best practices for this kind of task would be greatly helpful.
Avenash Sharma is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
2