⏱ Kubernetes operator that allows to set maximum lifetime for pods

Overview

Pod Lifetime Limiter

Hi! 👋 So you deal with a crappy application which stops working after some period of time and you want to restart it every N hours instead of fixing bugs? You found the right repository!

This program deletes all pods which has a label pod.kubernetes.io/lifetime. Label value should be in seconds, like pod.kubernetes.io/lifetime=86400 - 24 hours. Candidates to delete are determined by the following approach:

  1. The operator iterates over all containers inside the pod.
  2. It founds the container with maximum lifetime.
  3. It compares (start time + label value) to current time.
  4. If the first expression is less than second, the pod will be deleted.

Installation

The operator can be installed via Helm.

git clone https://github.com/nuetoban/pod-lifetime-limiter.git
helm install pod-lifetime-limiter ./pod-lifetime-limiter/helm -n kube-system

Usage

There are two ways to set max lifetime limit for pods.

  1. The common way - you can create resource PodLifetimeLimit.
kubectl apply -f - <<EOF
apiVersion: de3.me/v1
kind: PodLifetimeLimit
metadata:
  name: example-limit   
spec:
  maxLifetime: 3600
  selector:
    matchLabels:
      name: example-app         
EOF
  1. You can patch your deployments or pods via kubectl.
# Patch deployment
kubectl patch deployment YOUR-DEPLOYMENT --type json \
    -p='[{"op": "add",
          "path": "/spec/template/metadata/labels/pod.kubernetes.io~1lifetime",
          "value": "86400"}]'

# Or patch pod directly
kubectl patch pod YOUR-POD --type json \
    -p='[{"op": "add",
          "path": "/metadata/labels/pod.kubernetes.io~1lifetime",
          "value": "86400"}]'

TODO

  • Write unit tests
  • Add ability to set lifetime limit for job

This project is inspired by https://github.com/ptagr/pod-reaper. Idea of building the similar application looked like a good opportunity to learn Rust :)

You might also like...
🏝️ Set wallpaper from your terminal!

WLP Set wallpaper from your terminal. It works on Linux, Mac and Windows. Installation Manual git clone https://github.com/ahmadrosid/wlp.git cargo in

Rust TUI library - Clipping region is a set of min/max x/y values applied to the existing region

TinyBit Clipping region is a set of min/max x/y values applied to the existing region A TUI lib This is not yet production ready T O D O TODO: bugs: T

CLI application to run clang-format on a set of files specified using globs in a JSON configuration file.
CLI application to run clang-format on a set of files specified using globs in a JSON configuration file.

run_clang_format CLI application for running clang-format for an existing .clang-format file on a set of files, specified using globs in a .json confi

Set Shell Environment Variables across multiple shells with a single configuration file.

Xshe – Cross-Shell Environment Vars xshe allows for setting Shell Environment Variables across multiple shells with a single TOML configuration file.

CLI application to run clang-tidy on a set of files specified using globs in a JSON configuration file.
CLI application to run clang-tidy on a set of files specified using globs in a JSON configuration file.

run-clang-tidy CLI application for running clang-tidy for an existing .clang-tidy file on a set of files, specified using globs in a .json configurati

Librarian runs pre-configured commands against a group of files that match a set of filters

Filesystem Librarian Librarian runs pre-configured commands against a group of files that match a set of filters. The group of files is called a libra

An enhanced version of filetime, which can set file creation time on Windows.

filetime_creation Documentation An enhanced version of filetime, which can set file creation time on Windows. Internally, this use SetFileTime Win32 A

🍅 A command-line tool to get and set values in toml files while preserving comments and formatting

tomato Get, set, and delete values in TOML files while preserving comments and formatting. That's it. That's the feature set. I wrote tomato to satisf

This crate provides a set of functions to generate SQL statements for various PostgreSQL schema objects

This crate provides a set of functions to generate SQL statements for various PostgreSQL schema objects, such as tables, views, materialized views, functions, triggers, and indexes. The generated SQL statements can be useful for schema introspection, documentation, or migration purposes.

Owner
Viktor
Go Developer, former DevOps
Viktor
Rust based Kubernetes Operator to deploy K8s objects minimally.

kube-nimble nimble /ˈnɪmbl/ - quick and light in movement or action; agile. This project began from a place of curiosity about Kubernetes CRDs and the

Meet Vasani 3 Feb 26, 2024
Set of tools that make it easier for the operator to manage a TAPLE network.

⚠️ TAPLE is in early development and should not be used in production ⚠️ TAPLE Tools TAPLE (pronounced T+ ?? ['tapəl]) stands for Tracking (Autonomous

Open Canarias 5 Jan 25, 2023
Given a set of kmers (fasta format) and a set of sequences (fasta format), this tool will extract the sequences containing the kmers.

Kmer2sequences Description Given a set of kmers (fasta / fastq [.gz] format) and a set of sequences (fasta / fastq [.gz] format), this tool will extra

Pierre Peterlongo 22 Sep 16, 2023
tmplt is a command-line interface tool that allows you to quickly and easily set up project templates for various programming languages and frameworks

tmplt A User Friendly CLI Tool For Creating New Projects With Templates About tmplt is a command-line tool that lets users quickly create new projects

Humble Penguin 35 Apr 8, 2023
IntMaxRollup operator node & cli tools.

Intmax Rollup Operator Int max operator node Prepara Install rustup. rustup override set nightly

null 5 Jul 26, 2022
Expand your possibilities with the Try ? Operator

Expand your possibilities with the Try ? Operator Have you ever found yourself writing a function which may return early based on some condition? fn m

EC 1 Feb 1, 2022
A simple, C-like, ternary operator for cleaner syntax.

A simple ternary operator macro in rust. the iff! macro is the only item exported by this crate, it simply takes three expressions, seperated by ? and

KaitlynEthylia 42 May 23, 2023
Rust command line utility to quickly display useful secrets in a Kubernetes namespace

kube-secrets This is a command line utility for quickly looking at secrets in a Kubernetes namespace that are typically looked at by humans. It specif

Frank Wiles 8 Feb 10, 2022
A common library and set of test cases for transforming OSM tags to lane specifications

osm2lanes See discussion for context. This repo is currently just for starting this experiment. No license chosen yet. Structure data tests.json—tests

A/B Street 29 Nov 16, 2022
Quick'n dirty macro set for advent of code 2021

AOC quick'n dirty macro set Those are implemented using quick'n dirty procedural macros and libraries. Running the program Use cargo run --release --

Samuel Tardieu 3 Dec 25, 2021