Skip to content

Delete kubernetes pods by selector at chosen intervals

Notifications You must be signed in to change notification settings

tmegow/pod-terminator

Repository files navigation

pod-terminator

Deletes kubernetes pods by selector at chosen intervals

Configuration

The vars file contains a list of dictionaries, targets. targets entries contain 3 sub-keys:

  • Selector - (dict) selector string values (supports multiple)
  • namespace - (str) target namespace
  • interval - (str or int) int values are accepted as seconds values. Strings ending in s,m,h,d for specifying interval times are accepted. Remember to modify the example deletion schedules configured in the vars file with custom deletion schedules

Example

config:
  targets:
    - selector:
        app: "hello-kubernetes"
      namespace: "default"
      interval: "3h"
    - selector:
        name: "nginx"
        app: "data-sync"
      namespace: "data-sync"
      interval: "1d"

Usage

  • Install python requirements from requirements.txt file
    • virtualenv .venv; pip install -r requirements.txt
  • Run make "all" target to create docker container and template k8s manifests
    • make all
  • Review and apply k8s manifests
    • kubectl apply -f tmp-k8s/ #Example output below
$ kubectl apply -f tmp-k8s/
 clusterrole.rbac.authorization.k8s.io/delete-pods created
 clusterrolebinding.rbac.authorization.k8s.io/pod-terminator created
 configmap/pod-terminator created
 deployment.apps/pod-terminator created
 serviceaccount/pod-terminator created

About

Delete kubernetes pods by selector at chosen intervals

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published