A Kubernetes project to kill all namespace living over X times. Quite useful when auto-generated development environments on the fly and give them a lifecycle out-of-the-box from Kubernetes or even Helm.
docker run -ti -d --name=ns-killer germainlefebvre4/ns-killer
Docker image is avaiblable on Docker Hub.
kubectl apply -f kubernetes/CronJob
Python version needs to be:
3.7
3.8
Python versions 3.6
and under are not supported because of interpretation of datetime library.
The container has no parameters. Configuration is provided by a file at /etc/config/ns-killer
.
Configuration file is structured as following:
Attribute | Description | Values | Default | Implemented? |
---|---|---|---|---|
config.dryrun | Enable the dryrun mode | (string) enabled |
False | Yes |
config.retention.kind | Time unit for the frequency loop | (string) minutes , hours , days , weeks , months |
- | Yes |
config.retention.time | Time data for the frequency loop | (integer) | - | Yes |
config.namespace.exclude | List of namespaces to keep | list of (string) | - | Yes |
config.namespace.only | List of namespaces to delete. This parameter make the exclude list evicted. | list of (string) | - | Yes |
config:
dryrun: enabled
retention:
kind: hours
time: 2
namespace:
exclude:
- ns-killer
- kube-system
- kube-public
- kube-node-lease
- default
- ingress-nginx
- cert-manager
- gitlab-managed-apps
- cattle-system
- monitoring
- prometheus
- jenkins
- mongodb
- rabbitmq-ha
- wordpress
- gcr-cleanup
only: []
Let's run this image in a Kubernetes cluster.
Kubernetes manifest are present in directory kubernetes/.