Giter Club home page Giter Club logo

kube-job-cleaner's Introduction

kube-job-cleaner

Automatically delete completed Jobs.

In some cases, you cannot customize the kubernetes's component arguments. So it's impossible to support the job's ttlSecondsAfterFinished feature by add --feature-gates=TTLAfterFinished=true to controller, apiserver, scheduler arguments list.

And so it's come.

You just need to add a annotations(kube-job-cleaner/ttlSecondsAfterFinished) in the job. For example,

apiVersion: batch/v1
kind: Job
metadata:
  name: pi
  annotations:
    kube-job-cleaner/ttlSecondsAfterFinished: "30"
spec:
  template:
    spec:
      containers:
      - name: pi
        image: perl
        command: ["perl",  "-Mbignum=bpi", "-wle", "print bpi(2000)"]
      restartPolicy: Never

Deploy & Example

This is a example in kubernets cluster. Also you can deploy out of cluster.

# Create Namespace
kubectl create -f https://raw.githubusercontent.com/veezhang/kube-job-cleaner/master/deploy/namespace.yaml
# Create RBAC
kubectl create -f https://raw.githubusercontent.com/veezhang/kube-job-cleaner/master/deploy/rbac.yaml
# Create deployment
kubectl create -f https://raw.githubusercontent.com/veezhang/kube-job-cleaner/master/deploy/deployment.yaml
# Get the log
kubectl -n kube-job-cleaner logs -f -l app=kube-job-cleaner
# Open another terminal to create a job
kubectl create -f https://k8s.io/examples/controllers/job.yaml

Clearn

# Create deployment
kubectl delete -f https://raw.githubusercontent.com/veezhang/kube-job-cleaner/master/deploy/deployment.yaml
# Create RBAC
kubectl delete -f https://raw.githubusercontent.com/veezhang/kube-job-cleaner/master/deploy/rbac.yaml
# Create Namespace
kubectl delete -f https://raw.githubusercontent.com/veezhang/kube-job-cleaner/master/deploy/namespace.yaml

Command Usage

Usage of /usr/local/bin/kube-job-cleaner:
  -add_dir_header
        If true, adds the file directory to the header
  -alsologtostderr
        log to standard error as well as files
  -dry-run
        If true, only print the log.
  -job-check-interval int
        The job check interval secends. (default 60)
  -job-namespace string
        If non-empty, only watch this namespace; otherwise all namespaces.
  -job-resync-period int
        The job informer resync period secends. (default 60)
  -kubeconfig string
        Paths to a kubeconfig. Only required if out-of-cluster.
  -log_backtrace_at value
        when logging hits line file:N, emit a stack trace
  -log_dir string
        If non-empty, write log files in this directory
  -log_file string
        If non-empty, use this log file
  -log_file_max_size uint
        Defines the maximum size a log file can grow to. Unit is megabytes. If the value is 0, the maximum file size is unlimited. (default 1800)
  -logtostderr
        log to standard error instead of files (default true)
  -master --kubeconfig
        (Deprecated: switch to --kubeconfig) The address of the Kubernetes API server. Overrides any value in kubeconfig. Only required if out-of-cluster.
  -skip_headers
        If true, avoid header prefixes in the log messages
  -skip_log_headers
        If true, avoid headers when opening log files
  -stderrthreshold value
        logs at or above this threshold go to stderr (default 2)
  -v value
        number for the log level verbosity
  -vmodule value
        comma-separated list of pattern=N settings for file-filtered logging

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.