Useful Kubernetes One-liners

This post has some useful kubectl commands that might make your life easier managing k8s clusters.

I will keep this post updated when I come across something interesting to add :)

  • Get all pods in a non-running state:

kubectl get pods --field-selector=status.phase!=Running -A

  • Launch a network troubleshooting shell:

kubectl run -it --image nicolaka/netshoot troubleshooter

  • Force the restart of deployment pods:

kubectl rollout restart deployment yourdeploymentname

  • Check nodes

kubectl get nodes | grep node | awk '\''{print $1}'\'' | xargs -I {} sh -c '\''echo {} ; kubectl describe node {} | awk "/CPU Requests/,/Allocated/" ; echo '\'||||||||||||||||||||||||||||||'

  • Check top pods 

kubectl get nodes | grep node | awk '\''{print $1}'\'' | xargs -I {} sh -c '\''echo {} ; kubectl describe node {} | grep Allocated -A 5 | grep -ve Event -ve Allocated -ve percent -ve -- ; echo '\||||||||||||||||||||||||||||'


You'll only receive email when they publish something new.

More from Jorge André Gonçalves
All posts