Created
August 16, 2022 15:49
-
-
Save Markbnj/87a188b8c5515b627f556a9c46d34490 to your computer and use it in GitHub Desktop.
This file contains 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
get the IP addresses of a pod or pods | |
kubectl get pods [POD] -o=custom-columns=NAME:.metadata.name,PODIP:.status.podIP | |
get the name of the node a pod is scheduled on | |
kubectl get pods [POD] -o=custom-columns=name:.metadata.name,node:.spec.nodeName | |
get the resource requests and limits for a deployment | |
kubectl get deployment [DEPLOYMENT] -o go-template --template="{{range .spec.template.spec.containers}}{{printf \"%s %s\n\" .name .resources}}{{end}}" | |
get pods that have a >0 restart count | |
kubectl get --no-headers pods [POD] | awk '$4 > 0 {printf "%s %d\n",$1,$4}' | |
get pod ephemeral storage use on a node or nodes | |
for node in $(kubectl get --no-headers nodes [NODE] | awk '{print $1}'); do kubectl get --raw "/api/v1/nodes/${node}/proxy/stats/summary" | python3 -c """ | |
import sys, json | |
for pod in json.load(sys.stdin)['pods']: | |
print(f'{pod[\"podRef\"][\"name\"]} {pod[\"ephemeral-storage\"][\"usedBytes\"]/1048576:.2f}Mi') | |
"""; done |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment