Deletes kubernetes pods by selector at chosen intervals
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
config:
targets:
- selector:
app: "hello-kubernetes"
namespace: "default"
interval: "3h"
- selector:
name: "nginx"
app: "data-sync"
namespace: "data-sync"
interval: "1d"
- 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