Last active
October 12, 2023 22:00
-
-
Save ghelobytes/cf1648d5cc2f4411d2f294c37648f515 to your computer and use it in GitHub Desktop.
k8 scripts
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
# Show disk space info for all pod | |
n=mynamespace bash -c 'for pod in $(kubectl get pods -n $n -o=jsonpath="{.items[*].metadata.name}"); do echo $pod; kubectl exec -it $pod -n $n -- df -h; echo "\n"; done' |
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
# usage: delete_evicted_pods.sh my-namespace | |
kubectl get pod -n $1 | grep Evicted | awk '{print $1}' | xargs kubectl delete pod -n $1 |
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
# usage: get_logs.sh my-namespace | |
for pod in $(kubectl get pods -n $1 -o=jsonpath='{.items[*].metadata.name}'); do echo "Logs for Pod: $pod"; kubectl logs $pod -n $1; echo "------------------------------------------------------------"; done |
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
# usage: get_messages.sh my-namespace | |
for pod in $(kubectl get pods -n $1 -o=jsonpath='{.items[*].metadata.name}'); do echo "Messages for Pod: $pod"; kubectl describe $pod -n $1 | grep Message; echo "------------------------------------------------------------"; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment