Giter Site home page Giter Site logo

k8s-job-cleaner's Introduction

k8s-job-cleaner

Auto delete k8s jobs that Completed or Failed after ttl. This tool helps you, when your kubernetes cluster can not use TTL Controller. If your cluster can use TTL Controller, you should use it.

Usage

Usage of k8s-job-cleaner:
  -kubeconfig string
    	local kubeconfig if you run from outside cluster.
  -name string
    	master name if you run from outside cluster.
  -namespace string
    	namespace that you want watch jobs.
  -ttl int
    	ttl of completed or failed job deletion minutes. (default 10)
  -url string
    	master url if you run from outside cluster.

Authentication

To execute k8s-job-cleaner, your ClusterRole attached your account need this permimssion.

rules:
- apiGroups:
  - batch
  resources:
  - jobs
  - jobs/status
  verbs:
  - list
  - delete

If you use In-Cluster service account, you need to create ServiceAccount name: default to target namespace. see https://github.com/kubernetes/client-go/tree/master/examples/in-cluster-client-configuration https://github.com/kubernetes/client-go/tree/master/examples/out-of-cluster-client-configuration

how to test in minikube

$ minikube start
$ kubectl apply -f example/kubernetes/test_cleaner_in_cluster_config.yaml
# check job scheduled
$ kubectl get jobs -n test-k8s-job-cleaner
# check k8s-job-cleaner delete old jobs
$ kubectl logs `kubectl get pods -n test-k8s-job-cleaner -l app=k8s-job-cleaner --no-headers -o custom-columns=":metadata.name"` -n test-k8s-job-cleaner
delete job test-job-complete
delete job test-job-fail
# check job deleted
$ kubectl get jobs -n test-k8s-job-cleaner
# clean test resouces.
$ kubectl delete -f example/kubernetes/test_cleaner_in_cluster_config.yaml

k8s-job-cleaner's People

Stargazers

w1mvy avatar

Watchers

Takeshi Nakata avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.