Skip to content

Instantly share code, notes, and snippets.

@xsqian
xsqian / gist:cdcef2d2b7767fb5c67170e197168289
Created August 15, 2023 21:37
how to set the default namespace
kubectl config set-context --current --namespace=<insert-namespace-name-here>
# Validate it
kubectl config view --minify | grep namespace:
@xsqian
xsqian / delete-all-completed-pods.sh
Last active February 13, 2025 18:22
How to delete all the pods that are in Completed status in a k8s
kubectl get pod --field-selector=status.phase==Succeeded
kubectl delete pod --field-selector=status.phase==Succeeded
kubectl delete pod --field-selector=status.phase==Failed
kubectl delete pods $(kubectl get pod --all-namespaces -o jsonpath='{.items[?(@.status.containerStatuses[*].state.waiting.reason=="CrashLoopBackOff")].metadata.name}')