Search⌘ K
AI Features

Exploring Jenkins X Garbage Collection

Explore how Jenkins X handles the garbage collection of preview environments created from pull requests. Understand the role of Kubernetes CronJobs that periodically remove outdated activities, pods, and previews, ensuring efficient resource management without manual intervention. Learn how to verify and manually trigger garbage collection if needed while maintaining focus on other development tasks.

It would be silly for each preview environment to run forever. We need to figure out how to remove everything deployed as part of the pull request process for those that are already merged or closed. We could manually delete previews, but that would result in too much human involvement in something repetitive and predictable. We could create a script that would do that for us that would be executed periodically, but before we do that we should check whether Jenkins X already has some Kubernetes CronJobs.

Getting Kubernetes CronJobs

Shell
kubectl get cronjobs

The output is as follows.

D
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGE
jenkins-x-gcactivities 0/30 */3 * * * False 0 1h 3h
jenkins-x-gcpods 0/30 */3 * * * False 0 1h 3h
jenkins-x-gcpreviews 0 */3 * * * False 0 2h 3h

At the time ...