Skip to content

Instantly share code, notes, and snippets.

@zycon
Last active July 26, 2021 10:14
Show Gist options
  • Save zycon/df2bf77c35e8d64496717d71d37d06e3 to your computer and use it in GitHub Desktop.
Save zycon/df2bf77c35e8d64496717d71d37d06e3 to your computer and use it in GitHub Desktop.
Kubernetes Commands
### FILTER PODS
kubectl delete pods --field-selector=status.phase=Pending
### GET IMAGES
kubectl get pods -o jsonpath="{.items[*].spec.containers[*].image}" |tr -s '[[:space:]]' '\n' |sort |uniq -c
### Delete pods not running
kubectl get pods | grep -v Running | awk '{print $1}' | xargs kubectl delete pod
### Merge kubeconfig files
KUBECONFIG=~/.kube/config:~/.kube/new-config kubectl config view --flatten > ~/.kube/newconfig
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment