Skip to content

Instantly share code, notes, and snippets.

@magickatt
Created January 31, 2021 19:44
Show Gist options
  • Save magickatt/f058a18a73332b9dcf1940c68f056250 to your computer and use it in GitHub Desktop.
Save magickatt/f058a18a73332b9dcf1940c68f056250 to your computer and use it in GitHub Desktop.
Restart all deployments in a k8s namespace
#!/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