Hello
I see a large number of jobs for example sas-update-checker, sas-deployment-operator-reconcile ,sas-backu-job etc listed when I check for completed jobs using kubectl.
Can these completed jobs be deleted?
I always delete any adhoc start / stop jobs I create.
You can delete them, or for cronjobs you could change the configuration such that less history is retained.
CronJobs have a configurable successfulJobHistoryLimit and failedJobHistoryLimit.
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits
The default values are successful: 3 and failed: 1, but some of these the Viya deployment modifies, like for backups.
You can run this command to see which cronjobs are active and their JobHistoryLimit settings:
kubectl -n namespace get cronjob -o custom-columns=Name:.metadata.name,Suspended:.spec.suspend,SuccessLimit:.spec.successfulJobsHistoryLimit,FailLimit:.spec.failedJobsHistoryLimit
Here's the output from my environment:
Name Suspended SuccessLimit FailLimit sas-backup-purge-job false 7 7 sas-backup-pv-copy-cleanup-job true 100 1 sas-crunchy-platform-postgres-repo1-full false 3 1 sas-crunchy-platform-postgres-repo1-incr false 3 1 sas-import-data-loader false 3 1 sas-inventory-collector true 3 1 sas-pyconfig true 3 1 sas-restore-job true 100 1 sas-scheduled-backup-all-sources true 100 100 sas-scheduled-backup-incr-job true 100 100 sas-scheduled-backup-job false 100 100 sas-start-all false 3 1 sas-stop-all false 3 1 sas-studio-steps true 3 1 sas-update-checker false 3 1
To change this configuration and have it persist through updates you could use a patch transformer like this:
apiVersion: builtin kind: PatchTransformer metadata: name: sas-backup-jobs-change-history-retention patch: |- - op: replace path: /spec/successfulJobsHistoryLimit value: "10" - op: replace path: /spec/failedJobsHistoryLimit value: "10" target: kind: CronJob annotationSelector: sas.com/component-name=sas-backup-job version: v1
I use
kc [-n <namespace>] delete jobs --field-selector='status.successful=1'
You can delete them, or for cronjobs you could change the configuration such that less history is retained.
CronJobs have a configurable successfulJobHistoryLimit and failedJobHistoryLimit.
https://kubernetes.io/docs/concepts/workloads/controllers/cron-jobs/#jobs-history-limits
The default values are successful: 3 and failed: 1, but some of these the Viya deployment modifies, like for backups.
You can run this command to see which cronjobs are active and their JobHistoryLimit settings:
kubectl -n namespace get cronjob -o custom-columns=Name:.metadata.name,Suspended:.spec.suspend,SuccessLimit:.spec.successfulJobsHistoryLimit,FailLimit:.spec.failedJobsHistoryLimit
Here's the output from my environment:
Name Suspended SuccessLimit FailLimit sas-backup-purge-job false 7 7 sas-backup-pv-copy-cleanup-job true 100 1 sas-crunchy-platform-postgres-repo1-full false 3 1 sas-crunchy-platform-postgres-repo1-incr false 3 1 sas-import-data-loader false 3 1 sas-inventory-collector true 3 1 sas-pyconfig true 3 1 sas-restore-job true 100 1 sas-scheduled-backup-all-sources true 100 100 sas-scheduled-backup-incr-job true 100 100 sas-scheduled-backup-job false 100 100 sas-start-all false 3 1 sas-stop-all false 3 1 sas-studio-steps true 3 1 sas-update-checker false 3 1
To change this configuration and have it persist through updates you could use a patch transformer like this:
apiVersion: builtin kind: PatchTransformer metadata: name: sas-backup-jobs-change-history-retention patch: |- - op: replace path: /spec/successfulJobsHistoryLimit value: "10" - op: replace path: /spec/failedJobsHistoryLimit value: "10" target: kind: CronJob annotationSelector: sas.com/component-name=sas-backup-job version: v1
In my deployments., looks like the limits are not set.
Do I need to add the patch transformer to kustomization.yaml?
The SAS Users Group for Administrators (SUGA) is open to all SAS administrators and architects who install, update, manage or maintain a SAS deployment.
SAS technical trainer Erin Winters shows you how to explore assets, create new data discovery agents, schedule data discovery agents, and much more.
Find more tutorials on the SAS Users YouTube channel.