Design and implement a small program that finds pods in “bad” or “completed” states and forcibly delete them from the cluster, in order to avoid delaying deployments, or causing load on the Kubernetes API server.
The program should consider the cases where we want to forcefully delete, delete normally, or avoid taking action. Consider how this program will run on multiple clusters and how you would monitor the results across multiple clusters.
To test it, use the pod manifests, to reproduce a pod in Completed:
apiVersion: v1
kind: Pod
metadata:
name: successful-pod
namespace: default
spec:
containers:
- name: main
image: busybox:1.28
command: ["/bin/sh"]
args:
- "-c"
- "exit 0"
To test it, use the pod manifests, to reproduce a pod in Failed:
name: failed-pod
- "exit 1"
To test it, use the pod manifests, to reproduce a pod stuck in Terminating state:
name: terminating-pod
terminationGracePeriodSeconds: 50000
- "sleep 99999"
Already registered? Login
Not Account? Sign up
Enter your email address to reset your password
Back to Login? Click here