Exploring Jenkins X Garbage Collection
This lesson will discuss CronJobs in Jenkins X which will execute periodically to remove unused resources used in the preview environment.
We'll cover the following...
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
Press + to interact
kubectl get cronjobs
The output is as follows.
Press + to interact
NAME SCHEDULE SUSPEND ACTIVE LAST SCHEDULE AGEjenkins-x-gcactivities 0/30 */3 * * * False 0 1h 3hjenkins-x-gcpods 0/30 */3 * * * False 0 1h 3hjenkins-x-gcpreviews 0 */3 * * * False 0 2h 3h
At the time ...