During the Cold War between one of my female friends / (ex-)girlfriends ( She said that we were done ) in these days , there was a crazy idea flashed through my mind:
How about deleting ALL resources in production Kubernetes cluster environment without reasons?
So, I create such a super Kubernetes virus, I would like to call it kube-killer.
🤣 kube-killer
is a tool helping you kill (unused) kubernetes‘s resource.
You can delete kubernetes‘s resource (deploy,pod,statefulset and so on) based on time schedule ⏰, custom metrics or custom condition.
It is a humane killer, he could also freeze the deploy without killing it (scale to 0).
It is very lightweight and easy to use, you don't need to install any CRD.
You could run as web server, binary and CLI mode.
A long run web server using endless loop.
First of all,please make sure that:
- You are the master of the MYSQL .
root
is the best! And you should make sure that the MYSQL database is reachable for the remote Kubernetes cluster. - You are the administrator of the Kubernetes cluster. Admin of the “kube-system” will be the best!
You can create a scalable test environment by deleting those unused Kubernetes resources.
kube-killer
is another implement of serverless
.
You can DELETE THE KEY RESOURCE SNEAKILY if your boss have no plan to raise your salary.
Please do not use it for bad . (🤣I bet you will)
Just remember:
Easy to hurt, hard to forgive, just make FUN.
- kube-killer prepare
- prepare MYSQL
- prepare kube-killer server
- crashbackoff --> freeze deploy
- kill me
git clone https://github.com/p-program/kube-killer.git
make build
cp config/config-example.yaml config/config.yaml
# edit config.yaml depending on the actual situation
vi config/config.yaml
......
./kube-killer prepare
# It will create
# 1. MYSQL database
# 2. `kube-killer` web server
After that,you have two options: To be a demon or to be a Illidan(demon hunter).
./kube-killer run -mode demon
When kube-killer
run on the demon mode,It will KILL ALL PODS AT EVERY PERIOD.
Pods whoever create will be killed.
It is unstoppable.
./kube-killer run -mode Illidan
When kube-killer
run on the demon mode,it will hunt all unhealthy kubernetes resources at every period.
Such as 1. 1. 1. 1. 1.
Once the kube-killer server is ready,you can use the CLI mode .
# delete "my-wife" deployment after 10 mins
kube-killer kill deploy my-wife -a 10m
kube-killer kill deployment my-wife -a 10m
# delete deployment by label
kube-killer kill deploy -l age=two-hundred
kube-killer kill deployment -l age=two-hundred
# delete deployment by namespace and labels
kube-killer kill deploy -l age=two-hundred -n default
kube-killer kill deployment -l age=two-hundred -n default
# scale “my-girlfriends” deployment’s spec.replicas to 0 now
kube-killer freeze deployment my-girlfriends -a
# scale “my-girlfriends” deployment’s spec.replicas to 0 after 1 hour
kube-killer freeze deployment my-girlfriends -a 1h
You can find more examples in my test cases
You can expose the kube-killer server by using nodePort service .
Then the kube-killer server would become some kind of backdoor.
Finally,you are free to destroy the whole production Kubernetes cluster remotely (Hhhhhhhhhhhhhhhhhhhhh).
- freeze resource = kubectl scale --replicas=0 statefulset/web
- kill completed/failed pod automatically
- kill unused PV
- kill unused PVC
- kill service without pod
- kill node gracefully
- kill satan
- kill stucking namespace
- kill unused configmap
- kill unused secret
- output event
- custom metrics condition support
kube-killer kill po
kube-killer kill pod
kube-killer kill me
!!!WARNING!!!:PLEASE DO NOT USE.
It‘s an unpredictable command🤣.
- kill resource with metrics data.
Coding is easy, but it is really hard to figure out why she is so angry.
Should I tell her to DRINK MORE HOT WATER ?
What exactly does she want? Please tell me if you know the answer. Thank you very much!