Skip to content

Instantly share code, notes, and snippets.

@jellebens
Created June 11, 2024 11:43
Show Gist options
  • Save jellebens/9addfee270791941678586e639a1252e to your computer and use it in GitHub Desktop.
Save jellebens/9addfee270791941678586e639a1252e to your computer and use it in GitHub Desktop.
#!/bin/bash
# Define the namespace
NAMESPACE=$1
if [ -z "$NAMESPACE" ]; then
echo "Usage: $0 <namespace>"
exit 1
fi
# Get all pod names in the namespace
PODS=$(kubectl get pods -n $NAMESPACE -o jsonpath="{.items[*].metadata.name}")
# Delete each pod
for POD in $PODS; do
echo "Deleting pod $POD in namespace $NAMESPACE"
kubectl delete pod $POD -n $NAMESPACE
done
echo "All pods in namespace $NAMESPACE have been restarted."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment