Created
January 31, 2021 19:44
-
-
Save magickatt/f058a18a73332b9dcf1940c68f056250 to your computer and use it in GitHub Desktop.
Restart all deployments in a k8s namespace
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 | |
if [ "$#" -ne 1 ] | |
then | |
echo "Usage: restart_namespace \$NAMESPACE" | |
exit 1 | |
fi | |
NAMESPACE=$1 | |
echo "Restarting all deployments in $NAMESPACE..." | |
DEPLOYMENTS=`kubectl get deployments -n $NAMESPACE | tail -n +2 | cut -d ' ' -f 1` | |
for DEPLOY in $DEPLOYMENTS; do | |
kubectl rollout restart deployments/$DEPLOY -n $NAMESPACE | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment