https://github.com/hjacobs/kube-job-cleaner
DEPRECATED: Delete complete/failed Kubernetes jobs after one hour
https://github.com/hjacobs/kube-job-cleaner
cronjob jobs kubernetes
Last synced: 3 months ago
JSON representation
DEPRECATED: Delete complete/failed Kubernetes jobs after one hour
- Host: GitHub
- URL: https://github.com/hjacobs/kube-job-cleaner
- Owner: hjacobs
- License: gpl-3.0
- Archived: true
- Created: 2017-01-30T16:10:49.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2019-09-03T08:03:32.000Z (about 6 years ago)
- Last Synced: 2024-11-21T21:42:18.920Z (11 months ago)
- Topics: cronjob, jobs, kubernetes
- Language: Python
- Homepage:
- Size: 27.3 KB
- Stars: 98
- Watchers: 5
- Forks: 33
- Open Issues: 2
-
Metadata Files:
- Readme: README.rst
- License: LICENSE
Awesome Lists containing this project
README
======================
Kubernetes Job Cleaner
======================**DEPRECATED: this script is no longer needed with recent Kubernetes versions (1.12+) as long as you use ttlSecondsAfterFinished**
Very simple script to delete all completed jobs after X seconds (default: one hour).
Kubernetes jobs are not cleaned up by default and completed pods are never deleted.
Running jobs frequently (like every few minutes) quickly thrashes the Kubernetes API server with unnecessary pod resources. A significant slowdown of the API server can be observed with increasing number of completed jobs/pods hanging around.
To mitigate this, This small ``kube-job-cleaner`` script runs as a CronJob every hour and cleans up completed jobs/pods.See `Zalando's Running Kubernetes in Production document `_ for more information.
Building the Docker image:
.. code-block:: bash
$ make
Deploying:
.. code-block:: bash
$ kubectl apply -f deploy/
There are a few options:
``--seconds``
Number of seconds after job completion to remove the job (default: 1 hour)
``--timeout-seconds``
Kill all jobs after X seconds (default: never)
``--dry-run``
Do not actually remove any jobs, only print what would be done
``--namespace``
Only search for (and clean) jobs in a single namespace