Samples to cleanup multiple configs across multiple namespaces in Kubernetes using kubectl and GNU parallel
Last active
January 22, 2021 20:40
-
-
Save dlinsley/5e4b7bc47fd18d3046c8cf18d16a6511 to your computer and use it in GitHub Desktop.
Delete certain Kubernetes objects across all namespaces with parallel
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
kubectl get replicaset -A | awk '$3==0 && $4==0 && $5==0 {print $1,$2}' | parallel --jobs 4 --colsep ' ' kubectl delete replicaset -n {1} {2} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
kubectl get pods -A | grep 'Evicted' | awk '{print $1,$2}' | parallel --jobs 4 --colsep ' ' kubectl delete pod -n {1} {2} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/bin/bash | |
kubectl get secrets -A | grep 'istio.io/key-and-cert' | awk '{print $1,$2}' | parallel --jobs 4 --colsep ' ' kubectl delete secret -n {1} {2} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ $# -lt 1 ]; then | |
echo "Usage: getdeployresourcerequests <namespace>" | |
exit 1 | |
fi | |
kubectl get deploy -n $1 -o custom-columns=NAME:.metadata.name,CPU_Requests:.spec.template.spec.containers[].resources.requests.cpu,MEM_Requests:.spec.template.spec.containers[].resources.requests.memory |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment