Created
June 11, 2024 11:43
-
-
Save jellebens/9addfee270791941678586e639a1252e 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
#!/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