Giter VIP home page Giter VIP logo

completed-linkerd-job-cleaner's Introduction

completed-linkerd-job-cleaner

Automatically clean up completed Kubernetes Jobs with lingering Linkerd proxy sidecars.

Why does this exist?

When Pods created by Jobs and CronJobs in a Kubernetes cluster use a Linkerd service mesh, the Linkerd proxy sidecar container lives on after the main container terminates. This prevents the pod terminating, and so it hangs around in a NotReady state indefinitely.

There's two popular ways to handle this:

  • Make sure you don't put your Jobs and CronJobs in the service mesh, or
  • Update your jobs to call the /shutdown endpoint using linkerd-await or something similar.

This tool provides a third option: deployed to a cluster as a CronJob, it scans running Pods and deletes any that are complete (as well as the Job that owns them).

Pods will be deleted if all their containers have terminated, other than the linkerd-proxy sidecar container.

Jobs will be deleted if all the containers in a Pod they own other than the proxy have terminated with exit code 0.

Further reading: https://linkerd.io/2.12/tasks/graceful-shutdown/#graceful-shutdown-of-job-and-cronjob-resources

Running locally against a Kubernetes cluster

No artifacts are published other than the Docker image, so to run locally you'll need to check out the code and build it yourself.

Once you have, you can run against a cluster by providing a path to a kubeconfig file.

completed-linkerd-job-cleaner -kubeconfig ~/.kube/config

Options available

$ ./completed-linkerd-job-cleaner -help
Usage of ./completed-linkerd-job-cleaner:
  -kubeconfig string
    	Path to kubeconfig file, for running externally to a cluster
  -shutdown-self
    	Post to http://localhost:4191/shutdown to shut down our own proxy when finished (default if -kubeconfig is not provided)
  -verbose
    	Enable verbose logging

Deploying to Kubernetes

Running completed-linkerd-job-cleaner in a cluster requires permissions to list pods and delete jobs. There's an example in resources.yaml.

If the required service account is attached, the published image should work straight out of the box.

Building

The project should build easily using Go.

go build

completed-linkerd-job-cleaner's People

Contributors

mdmoss avatar

Watchers

 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.